Recent Feedback
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
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!
Here is a link!
DANGEROUS URL REMOVED
I am norwegian, so some of the label names are XX XXXXXXXXX, but I hope it doesn't make any problem understanding!
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
Hopefully shouldn't be a problem!
I just linked the code for the form I have trouble with.
It is not an exe, it is an vb. file
Did it work`?
Should I try to link it again?
Sorry it did not work. Yes please try to link again. Perhaps ZIP the file, this should gaurantee success. Thanks!
do you think it would work if I write the code in a doc-file? and then zip it?
http://wikisend.com/download/622936/Imports MySql.zip
here is the link again. forum link: Imports MySql.zip
Thank you, I have successfully downloaded the project and will begin to look at it.
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?
Yes, this is what i want to do. change the where-statement!
Do you mind answer another question? About MySql? I have my exam, so this is why I'm asking!
Of course you may ask another question!
So what you need to do, is add a Parameter to the Fill method of your Table adapter
Click the dataset in the data sources window, and then click 'edit dataset with designer'
Then, where you have your table adapter right click where it says Fill
click configure and you can add a parameter through here
for instance it could say SELECT distinct spmTekst from tblsporsmal, tblevaluering, tblalternativ where tblsporsmal.spmEvalID = tblevaluering.evalID and tblsporsmal.spmID = tblalternativ.altSpmID and evalNavn = ?
as you see, you will put a question mark where you wish to have the variable
then you can change your call to
da.Fill(ds, ValueToSendToParameter)
thank you so much for you answer! I managed to fix it! But now I have another question!
Great!
Go ahead
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.
Hope you understood!
where all the questions have 5 alternatives each.
what do you mean by alternative?
answers?
yes! answers
=) ok thanks...Im just making sure i am understanding correctly!
Ok so basically you'd like to show a chart in visual basic
of how many people answered the question correctly?
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.
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
Ok so your first thing to do would be to get all of these choices into an ArrayList
For each answer, arraylist.add(answer)
could this be done automatically from the database? because the questions and answers is in the databse
Oh yes
To use your database and charts, I would look into Crystal Reports
Sorry for my many questions, but I have my exam now!
Its ok!
Crystal Reports is the way to use your database and make charts automatically
It is pretty complex subject, however
okey
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
So the first thing to do is to follow these steps?
yes, but it is something that will take a few hours to learn
okay
I wish I could give you the quick and easy answer, but for charts and databases there is no quick and simple way
that's okay! I will try do this! Thank you so much
You are welcome! Good luck! Please let me know if you have any other questions
Experience: Lead Software Engineer at one of the largest Printing Presses on East Coast
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?
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.htmRemember, 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!
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")
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?
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?