Login|Contact Us
Question and Answer

Programming

Ask a Programming Question, Get an Answer ASAP!

  • Ask A Question
  • Browse Answers
  • Meet The Experts
  • How JustAnswer Works

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

 
shorecc's Avatar
  • Answered by:shorecc
  • Computer Software Engineer
  • Positive Feedback: 100.0 %
  • Accepted Answers: 44
Verified Expert
in Programming

Recent Feedback

Positive
Thanks for the help!
Positive
Excellent. Fast and very knowledgeable.
Positive
Super fast and helpful, thanks again!
Positive
I appreciate his experience and help that was provided to me.
Positive
brilliant, effective, fast
Positive
Thanks that worked great
Positive
OH MY GOODNESS! this simple act fixed the problem where all the other "experts"...
Positive
quick and easy
Positive
Thanks for your help. I will be waiting for your answer.
Positive
shorecc was a great help!!!! My question was answered quickly

Customer 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?

 

Optional Information:
Language (or Software): Visual Basic

Already Tried:
Just IF-sentences

Submitted: 353 days and 13 hours ago.
Category: Programming
Value: kr 294
Status: CLOSED

Accepted Answer

Picture
Expert:  shorecc replied 353 days and 12 hours 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 XX XXXXXXXXX, but I hope it doesn't make any problem understanding!

shorecc :

Thank you, for some 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, I have 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

Expert TypeComputer Software Engineer
Category: Programming
Pos. Feedback: 100.0 %
Accepts: 44
Answered: 5/3/2012

Experience: Lead Software Engineer at one of the largest Printing Presses on East Coast

Ask this Expert a Question >
Customer replied 351 days and 15 hours 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?

Picture
Expert:  shorecc replied 351 days and 8 hours 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 350 days and 20 hours 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")

Picture
Expert:  shorecc replied 349 days and 13 hours 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 165 days and 15 hours 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?


 


 


 


 


 


 

 
Tweet

3 Programmers are Online Right Now

Ask Your Question Now
Programming Questions Date Submitted
I need a program in visual basic 2010 that does the following:1. 4/17/2013
RA-JPM 4/17/2013
RA-hg 4/17/2013
Hi need help with a specific 102 programming assignment. 4/16/2013
I have a very serious issue with Magento coupon system which 4/16/2013
Programming Challenge 4/16/2013
RA-ke 4/16/2013
1. (TCO 9) Menu-driven programs should be broken down into 4/15/2013
I need an app builder to build an app OKPR415211 4/15/2013
will tip extra if finished fast - programming assignment 4/14/2013
RSS
Next 10 >
Ask A Programmer
Type Your Programming Question Here...
characters left:

Top Programming Experts

See More Programmers

In The News

Nbc
Washington Post
New York Times
Cnn
Learn More

How It Works

  • Ask an Expert
  • Get a Professional Answer
  • Ask Followup Questions
  • 100% Satisfaction Guarantee
Learn More
close
Find Expert answers related to your question.
Sign up using email
We will never post anything without your permission.
Already have an account? Sign in

Ask a Programmer

Get a Professional Answer. 100% Satisfaction Guaranteed.
87 Programmers are Online Now
Type Your Programming Question Here...
characters left:
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.
Truste
Contact Us | Terms of Service | Privacy & Security | About Us | Our Network
© 2003-2013 JustAnswer LLC
  • Pearl.com
  • JustAnswer UK
  • JustAnswer Germany
  • JustAnswer Spanish
  • JustAnswer Japan