TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Yasmine Amin
NA
20
0
ComboBox leave event .net 1.1
Sep 11 2009 5:06 AM
Hi All I'm trying to develop a windows based application and i'm stuck at the minute I have a update item form where it displays the item details. in the onload event i have the following private void UpdateItem_Load(object sender, System.EventArgs e) { //to get all suppliers update_changeSuppCB.Enabled = false; string getItemSupp = "SELECT suppliers_name FROM Suppliers"; //SqlCommand getItemSuppCmd = new SqlCommand(getItemSupp, conn); SqlDataAdapter getItemSuppAdp = new SqlDataAdapter(getItemSupp, conn); DataSet getItemSuppDs = new DataSet(); try { conn.Open(); //getItemSuppCmd.ExecuteReader(); //update_changeSuppCB. getItemSuppAdp.Fill(getItemSuppDs, "Suppliers"); update_changeSuppCB.DataSource = getItemSuppDs.Tables[0]; update_changeSuppCB.DisplayMember = "suppliers_name"; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { conn.Close(); } }//end of load event in the form i have a combo box with a leave event with the following code private void update_changeSuppCB_Leave(object sender, System.EventArgs e) { string suppName = update_changeSuppCB.Text; //now to get the id of the suppliers name (note i'm calling another class to get the suppliers id) int suppId = getCatSuppId.getSupplierId(suppName); //if the user selected a different supplier then go ahead with the change else do nothing if (suppName != update_suppliersTxt.Text) { string updateSupp = "UPDATE Items SET supplier_id = " + suppId + " WHERE id = " + update_itemIdTxt.Text; SqlCommand updateSuppCmd = new SqlCommand(updateSupp, conn); try { conn.Open(); updateSuppCmd.ExecuteNonQuery(); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { conn.Close(); } } } the problem is i'm getting "Invalid Operation Exception- The connection is already open" now this is happening because after executing this line update_changeSuppCB.DataSource = getItemSuppDs.Tables[0]; The leave event (private void UpdateItem_Load(object sender, System.EventArgs e)) is being called. Why is it being called.. shouldnt only be called after leaving away from the combobox. Thank you in advance
Reply
Answers (
2
)
cant find center directry
code for caps lock on tooltip dispay