How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask shorecc Your Own Question
shorecc
shorecc, Computer Software Engineer
Category: Programming
Satisfied Customers: 148
Experience:  Lead Software Engineer at one of the largest Printing Presses on East Coast
56103045
Type Your Programming Question Here...
shorecc is online now
A new question is answered every 9 seconds

Hi. I have a database created in Mysql, and I am using Visual

Resolved Question:

Hi. I have a database created in Mysql, and I am using Visual Basic. Then I have a combobox with datas from one of the tables, f.example a table: CustomersID, CustomersName. I have managed to show CustomersName in the combobox, but I want to show datas from a select-sentence when i click the OK-button!

For now I am using an IF-sentence for each row, and this would be difficult if I have 1,000 different dataes. Here's is my code with IF-sentence:

If cmBoxEval.Text = "Sluttevluering i Info 1" Then
lblSpørsmål.Visible = True
minCommand.CommandText = "select distinct spmTekst from tblsporsmal, tblevaluering, tblalternativ where tblsporsmal.spmEvalID = tblevaluering.evalID and tblsporsmal.spmID = tblalternativ.altSpmID and evalNavn = 'Sluttevluering i Info 1'"
tblsporsmal.Clear()
minAdapter.Fill(tblsporsmal)
BindingSpørsmål.DataSource = tblsporsmal
navSpørsmål.BindingSource = BindingSpørsmål
lblSpørsmål.DataBindings.Clear()
lblSpørsmål.DataBindings.Add("Text", BindingSpørsmål, "spmTekst")

So, what I really want to do is to use the same select-sentence on the lines 3,4,5 but change the "evalNavn" automatically to the selected item in the combobox! Is this possible? Or do you have another way to do it?
Submitted: 4 years ago.
Category: Programming
Expert:  shorecc replied 4 years ago.

shorecc :

Hello, I believe this is possible, but I would need to see the code to see more clearly what you are trying to do. If you could please post your project on www.wikisend.com it will provide you with a download link for me. Copy and paste that link here, then we can take a closer look. Thanks!

Customer:

Here is a link!

Customer:

DANGEROUS URL REMOVED

Customer:

I am norwegian, so some of the label names are XXXXX XXXXX but I hope it doesn't make any problem understanding!

shorecc :

Thank you, XXXXX XXXXX reason it is saying DANGEROUS URL REMOVED is this an exe? Please ZIP these files and then the system will allow the link

shorecc :

Hopefully shouldn't be a problem!

Customer:

I just linked the code for the form I have trouble with.

Customer:

It is not an exe, it is an vb. file

Customer:

Did it work`?

Customer:

Should I try to link it again?

shorecc :

Sorry it did not work. Yes please try to link again. Perhaps ZIP the file, this should gaurantee success. Thanks!

Customer:

do you think it would work if I write the code in a doc-file? and then zip it?

Customer:

http://wikisend.com/download/622936/Imports MySql.zip

Customer:

here is the link again. forum link: Imports MySql.zip

shorecc :

Thank you, XXXXX XXXXX successfully downloaded the project and will begin to look at it.

shorecc :

From what I understand, is you wish to run a SELECT statement automatically and loop through it a few times, changing the sql statement a little each time? Please advise if this is correct, if not could you clarify your question a little more?

Customer:

Yes, this is what i want to do. change the where-statement!

Customer:

Do you mind answer another question? About MySql? I have my exam, so this is why I'm asking!

shorecc :

Of course you may ask another question!

shorecc :

So what you need to do, is add a Parameter to the Fill method of your Table adapter

shorecc :

Click the dataset in the data sources window, and then click 'edit dataset with designer'

shorecc :

Then, where you have your table adapter right click where it says Fill

shorecc :

click configure and you can add a parameter through here

shorecc :

for instance it could say SELECT distinct spmTekst from tblsporsmal, tblevaluering, tblalternativ where tblsporsmal.spmEvalID = tblevaluering.evalID and tblsporsmal.spmID = tblalternativ.altSpmID and evalNavn = ?

shorecc :

as you see, you will put a question mark where you wish to have the variable

shorecc :

then you can change your call to


da.Fill(ds, ValueToSendToParameter)

Customer:

thank you so much for you answer! I managed to fix it! But now I have another question!

shorecc :

Great!

shorecc :

Go ahead

Customer:

I have made a quiz in SQL where all the questions have 5 alternatives each. Then I have a SQL-sentence which is printing out which alternative the persons who have taken the quiz have been choosen when they answered. This SQL-sentence is: select spmTekst as Spørsmål, alttekst as Alternative, count(*) from tblsvar, tblalternativ, tblsporsmal, tblevaluering where svaraltid = altid and altspmid = spmid and tblevaluering.evalID = tblsporsmal.spmEvalID and evalNavn = 'Sluttevaluering i Mat 2' group by svaraltid. This sentence prints out the questiontekst, the alternative text and how many persons who has answered the alternativ on that question. Now, I want to show this statistic with a chart in visual basic! With the X-value is the alternativID and Y-value is how many persons who answered the alternative.

Customer:

Hope you understood!

shorecc :

where all the questions have 5 alternatives each.

shorecc :

what do you mean by alternative?

shorecc :

answers?

Customer:

yes! answers

shorecc :

=) ok thanks...Im just making sure i am understanding correctly!

shorecc :

Ok so basically you'd like to show a chart in visual basic

shorecc :

of how many people answered the question correctly?

Customer:

yes! all the questions have different alternatives (possible answers). and I want to show how many people answered the question, or more precisly which answer they chose.

Customer:

one question could be (an example). What does the dog says? a) Voff b) Mjau c) zz. And I want to show how many people who choosed a),b) and c)1

shorecc :

Ok so your first thing to do would be to get all of these choices into an ArrayList

shorecc :

For each answer, arraylist.add(answer)

Customer:

could this be done automatically from the database? because the questions and answers is in the databse

shorecc :

Oh yes

shorecc :

To use your database and charts, I would look into Crystal Reports

Customer:

Sorry for my many questions, but I have my exam now!

shorecc :

Its ok!

shorecc :

Crystal Reports is the way to use your database and make charts automatically

shorecc :

It is pretty complex subject, however

Customer:

okey

shorecc :

Please refer to : http://www.codeproject.com/Articles/142064/Step-by-Step-Creation-of-Crystal-Report-using-its for a complete explanation of Crystal Reports/Databases/Charts

Customer:

So the first thing to do is to follow these steps?

shorecc :

yes, but it is something that will take a few hours to learn

Customer:

okay

shorecc :

I wish I could give you the quick and easy answer, but for charts and databases there is no quick and simple way

Customer:

that's okay! I will try do this! Thank you so much

shorecc :

You are welcome! Good luck! Please let me know if you have any other questions

shorecc and other Programming Specialists are ready to help you
Customer: replied 4 years ago.
Hi. I want to export data from a datagrid to excel. Do you have any good tip to do this in a simple and quickly way?
Expert:  shorecc replied 4 years ago.
Hello,
Here is a website that shows a quick and simple way :
http://vb.net-informations.com/excel-2007/vb.net_export_from_datagridview_to_excel.htm

Remember, if for any reason you are unsatisfied with my answer, we can continue the conversation until you’re satisfied and Accept my answer. I can address follow up questions at no extra charge and I’m always here to help. Thank you for using JustAnswer!
Customer: replied 4 years ago.
Now, I've tried the code you gave me from the internet site, but I get an error!
COM Exeption was unhandled. Invalid Index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
the error occured on this line: xlWorkSheet = xlWorkBook.Sheets("sheet1")
Expert:  shorecc replied 4 years ago.
This means an index you have created is going out of bounds somewhere, are you sure you are not going outside the parameters of the array?
Customer: replied 4 years ago.

Hi!


I have some howework in JAVA programming where I want to register some animals. I have a class called Animals with constructor and different variables. (String id, String sex etc.)


Then I have a menu in another class called Kontroll with different choices to navigate. In this menu I use case as navigation. (example, press 1 for animals, 2 for other animals etc.)


Then I have a method with questions about animalinformation and then put the information into an arraylist. I have managed to write the code for the method right ( I think), but when I'm going to open the method in the case-statement I get an error: "Method RegNyHare in class Brukergrensenitt cannot be applied to given types". Here's my code. Some help with this error?


 


The part of the case:


switch (menyRegValg){
case 1:
Brukergrensesnitt.RegNyHare(); --> RegNyHare is where I get an error!


 


Brukergrensesnitt class:


 


public static void RegNyHare(String id, int kjønn, double vekt, double lengde, String dato, String fangststed, String HareFarge, String HareType){ ;
ArrayList hareListe= new ArrayList();
java.util.Scanner scan = new java.util.Scanner(System.in);

id = "H" + (hareListe.size() + 1);
Hare nyHare = new Hare(id, kjønn, vekt, lengde, dato, fangststed, HareFarge, HareType);
System.out.println("VENNLIGST SKRIV INN INFORMASJON OM NY HARE. "+(id));
System.out.print("Kjønn, 1 for hann eller 2 for hunn: ");
kjønn = scan.nextInt();
System.out.print("Vekt på hare (i kg) : ");
vekt = scan.nextDouble();
System.out.print("Lengde på hare (i cm): ");
lengde = scan.nextDouble();
System.out.print("Dato for fangst : ");
dato = scan.nextLine();
System.out.print("Sted for fangst : ");
fangststed = scan.nextLine();
System.out.print("Pelsfarge, B for brun eller H for hvit : ");
HareFarge = scan.nextLine();
System.out.print("Type hare, V for vanlig eller S for sørhare : ");
HareType = scan.nextLine();
hareListe.add(nyHare);
System.out.println("Du har nå registrert følgende opplysninger på ny hare :" + nyHare);


}


 


Do I get this error because I have RegNyHare(); in the case, and RegNyHare (String id, String ... etc) in the method?