binding list box URGENT!!!!

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2009
Posts: 1
Reputation: raghunandan_l is an unknown quantity at this point 
Solved Threads: 0
raghunandan_l raghunandan_l is offline Offline
Newbie Poster

binding list box URGENT!!!!

 
0
  #1
Jan 7th, 2009

hey friends i need a help urgently....
i'm doing a project where i use listbox...i'm facing problem with this
firstly i'm populating a listbox with particular field...then on clicking particular item in listbox the corresponding records from database should get displayed in all the textboxes of the form...here's a sample code which i treid but there's problem.....
after modifying or deleting particular record the first item record doesnot get displayed in textbox....plzzzz sought out my problem....
private void Form1_Load(object sender, System.EventArgs e) {
         string connString = "server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI";
  
         string sql = @"select firstname, lastname from employee ";

         SqlConnection conn = new SqlConnection(connString);
         SqlDataAdapter da = new SqlDataAdapter(sql, conn);
         da.Fill(dataSet1, "employee");
         DataTable dt = dataSet1.Tables["employee"];

         listBox1.DataSource = dt;
         listBox1.DisplayMember = "firstname";

         textBox1.DataBindings.Add("text", dt, "firstname");

         textBox2.DataBindings.Add("text", dt, "lastname");

      }
    }
i'm using vb.net 2003 and ms access but code is foe sql which i can convert it to oledb later....
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: binding list box URGENT!!!!

 
0
  #2
Jan 7th, 2009
First of all it's VB.NET forum you should put your question on C# forum.
Get us the code which you delete\update records by.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,486
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 517
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: binding list box URGENT!!!!

 
0
  #3
Jan 7th, 2009
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC