how i can fetch list box with Names vb. net?
-
Dear everyone. hope you all will be fine and good in health. i have a problem that i want to fetch a listbox with names. please help me that what code i have to write. PICTURE IS HERE; i have a table STUDENT with attributes (ID, Name, Age) i have inserted 100 students record into STUDENT tabl i have a listbox control named lstStdents on my form now i want that when my form is opened, it should auotmatically fill the listbox with NAME of students i want to know that how to fill that box using datareader? thanks
-
Dear everyone. hope you all will be fine and good in health. i have a problem that i want to fetch a listbox with names. please help me that what code i have to write. PICTURE IS HERE; i have a table STUDENT with attributes (ID, Name, Age) i have inserted 100 students record into STUDENT tabl i have a listbox control named lstStdents on my form now i want that when my form is opened, it should auotmatically fill the listbox with NAME of students i want to know that how to fill that box using datareader? thanks
http://msdn2.microsoft.com/en-us/library/haa3afyz(VS.71).aspx Try like that.
OleDbConnection nwindConn = new OleDbConnection("Provider=MSDataShape;Data Provider=SQLOLEDB;" + "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind"); OleDbCommand custCMD = new OleDbCommand("SELECT Name from STUDENT", nwindConn); nwindConn.Open(); OleDbDataReader custReader = custCMD.ExecuteReader(); while (custReader.Read()) { Listbox1.AddItem(custReader.GetString(1) = CompanyName); } custReader.Close(); nwindConn.Close();
do searching a lit bit. man.... there are a lot of examples about how to populate the data into listbox in web or our forum....Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
http://msdn2.microsoft.com/en-us/library/haa3afyz(VS.71).aspx Try like that.
OleDbConnection nwindConn = new OleDbConnection("Provider=MSDataShape;Data Provider=SQLOLEDB;" + "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind"); OleDbCommand custCMD = new OleDbCommand("SELECT Name from STUDENT", nwindConn); nwindConn.Open(); OleDbDataReader custReader = custCMD.ExecuteReader(); while (custReader.Read()) { Listbox1.AddItem(custReader.GetString(1) = CompanyName); } custReader.Close(); nwindConn.Close();
do searching a lit bit. man.... there are a lot of examples about how to populate the data into listbox in web or our forum....Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
Dear Micheal thanks for nice information i have writen my code following your pattern but it not works Dim con As New OleDb.OleDbConnection("Provider=Microsoft.jet.oledb.4.0;Data Source=e:\college.mdb") Dim query As New OleDb.OleDbCommand("Select * from student") con.Open() Dim dr As OleDb.OleDbDataReader = query.ExecuteReader() While (dr.Read()) ListBox1.Items.Add(dr.GetString(1) = Name) End While dr.Close() con.Close() please help me more to clear my concept thanks
-
Dear Micheal thanks for nice information i have writen my code following your pattern but it not works Dim con As New OleDb.OleDbConnection("Provider=Microsoft.jet.oledb.4.0;Data Source=e:\college.mdb") Dim query As New OleDb.OleDbCommand("Select * from student") con.Open() Dim dr As OleDb.OleDbDataReader = query.ExecuteReader() While (dr.Read()) ListBox1.Items.Add(dr.GetString(1) = Name) End While dr.Close() con.Close() please help me more to clear my concept thanks
Egoest wrote:
Dim query As New OleDb.OleDbCommand("Select * from student")
Select **Name** from student
Egoest wrote:
ListBox1.Items.Add(dr.GetString(1) = Name)
ListBox1.Items.Add(dr.GetString(1))
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)