here's my sample program in my addProducts.. if i click my save button.. when i run it, i prompts an error message that reader is closed.. can anyone help me? private void btnSaveChangesObject_Click(object sender, EventArgs e) { try { clsPublic.objConn.Open(); OdbcCommand com = new OdbcCommand("Select Name from Products", clsPublic.objConn); OdbcDataReader read; read = com.ExecuteReader(); while (read.Read()) { if (read[0].ToString() == txtprodname.Text) { MessageBox.Show("Error!"); } else try { String strSQL; if (clsPublic.BoolUpdateProductsRec == true) { strSQL = "Update products Set Id = '" + txtprodId.Text + "', Name = '" + txtprodname.Text + "', Description = '" + txtdesc.Text + "', Type = '" + txttype.Text + "', Price = '" + txtprice.Text + "', Brand = '" + txtbrand.Text + "' where Id = '" + txtprodId.Text + "'"; } else { strSQL = "Insert Into products Values('" + txtprodId.Text + "', '" + txtprodname.Text + "', '" + txtdesc.Text + "', '" + txttype.Text + "', '" + txtprice.Text + "', '" + txtbrand.Text + "')"; } SaveObjectRecord(strSQL); btnCloseSaveChangesObject.PerformClick(); } catch (NullReferenceException NRE) { MessageBox.Show("Error:" + NRE.Message, "ARTM", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
cutedrew
Posts
-
reader is closed how can i solve this -
can someone help me...i have a problem with my c# project.. im using a listview grid in generating my database. and my problem is that it won't increment the number.. can anyone help me?? plss
-
about combo boxin joining the data in a certain in the database.. but how can i join this data using combo box?? can someone help me..
-
can someone help me in designing my MDi or my mainform..a design that is simple but can make others shock when they see it.. anyone.. pls help me..
-
can someone help me in this program..I have a program in our project named sales and stocks monitoring sytem in which it monitors the sales, products, and stocks.. it has stock in and stock out and it's sales has a charge and cash.. Anyone knows how to do this??
-
can someone help me to code add, edit, delete, search in mysql database using C#..anyone knows??
-
sample code using combo box database in mysql..can someone help me, need it badly.
-
anyone can give me sample syntax or code in update using mysql in c#??anyone.. plss... nid it badly..
-
How to connect Mysql database wamp from C#?Can anyone teach me or show me some tutorials how to connect.. I need it badly..
-
help to create inventory system??how can i create inventory system with database?? plss help me..