Any idea why this error appears (SEH Exception)
-
I get http://www.postimage.org/image.php?v=Pq1N1qmr[^] <- this error on one of the computers. Dont know why. this is the code:
try
{
label12.ForeColor = Color.Black;
string dbConnComm = "INSERT INTO Vnosi ([Dostava],[Skatla],[Barkoda],[Oznaka],[Skener],[Operater],[Datum],[PosnetkiV3],[PosnetkiM3],[Opombe]) VALUES ("
+ cmbDostava.Text + ", "
+ cmbSkatla.Text + ", '"
+ cmbBarkoda.Text + "', '"
+ cmbEnota.Text + "', '"
+ cmbSkener.Text + "', '"
+ cmbOperater.Text + "', '"
+ cmbDatum.Text + "', "
+ txtVA3.Text + ", "
+ txtMA3.Text + ", '"
+ txtOpombe.Text + "')";SqlConnection dbConn = new SqlConnection(sqlConnection); dbConn.Open(); SqlCommand dbComm = new SqlCommand(dbConnComm, dbConn); dbComm.ExecuteNonQuery(); dbConn.Close(); label12.Text = "Uspešno vnešeno"; } catch(Exception ex) { label12.ForeColor = Color.Red; label12.Text = "Napaka pri vnosu"; MessageBox.Show("Napaka: " + ex.ToString()); }
PC has framework 2.0 and 1.1
-
I get http://www.postimage.org/image.php?v=Pq1N1qmr[^] <- this error on one of the computers. Dont know why. this is the code:
try
{
label12.ForeColor = Color.Black;
string dbConnComm = "INSERT INTO Vnosi ([Dostava],[Skatla],[Barkoda],[Oznaka],[Skener],[Operater],[Datum],[PosnetkiV3],[PosnetkiM3],[Opombe]) VALUES ("
+ cmbDostava.Text + ", "
+ cmbSkatla.Text + ", '"
+ cmbBarkoda.Text + "', '"
+ cmbEnota.Text + "', '"
+ cmbSkener.Text + "', '"
+ cmbOperater.Text + "', '"
+ cmbDatum.Text + "', "
+ txtVA3.Text + ", "
+ txtMA3.Text + ", '"
+ txtOpombe.Text + "')";SqlConnection dbConn = new SqlConnection(sqlConnection); dbConn.Open(); SqlCommand dbComm = new SqlCommand(dbConnComm, dbConn); dbComm.ExecuteNonQuery(); dbConn.Close(); label12.Text = "Uspešno vnešeno"; } catch(Exception ex) { label12.ForeColor = Color.Red; label12.Text = "Napaka pri vnosu"; MessageBox.Show("Napaka: " + ex.ToString()); }
PC has framework 2.0 and 1.1
A few quick question to help try find the answer. Have you tried the insert into the database directly and dose it work? What is the connection string you are using as it appears to be a connection issue? Can you connect to the database from that machine? Why are you using an insert? you should look at using a stored procedure as direct sql asks for an injection attack.
-
I get http://www.postimage.org/image.php?v=Pq1N1qmr[^] <- this error on one of the computers. Dont know why. this is the code:
try
{
label12.ForeColor = Color.Black;
string dbConnComm = "INSERT INTO Vnosi ([Dostava],[Skatla],[Barkoda],[Oznaka],[Skener],[Operater],[Datum],[PosnetkiV3],[PosnetkiM3],[Opombe]) VALUES ("
+ cmbDostava.Text + ", "
+ cmbSkatla.Text + ", '"
+ cmbBarkoda.Text + "', '"
+ cmbEnota.Text + "', '"
+ cmbSkener.Text + "', '"
+ cmbOperater.Text + "', '"
+ cmbDatum.Text + "', "
+ txtVA3.Text + ", "
+ txtMA3.Text + ", '"
+ txtOpombe.Text + "')";SqlConnection dbConn = new SqlConnection(sqlConnection); dbConn.Open(); SqlCommand dbComm = new SqlCommand(dbConnComm, dbConn); dbComm.ExecuteNonQuery(); dbConn.Close(); label12.Text = "Uspešno vnešeno"; } catch(Exception ex) { label12.ForeColor = Color.Red; label12.Text = "Napaka pri vnosu"; MessageBox.Show("Napaka: " + ex.ToString()); }
PC has framework 2.0 and 1.1
Don't use concatenation for building sql queries, it's dangerous. Read more here: Parametrized Queries VS String Concatenation[^]
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
-
Don't use concatenation for building sql queries, it's dangerous. Read more here: Parametrized Queries VS String Concatenation[^]
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
Yes Giorgi, thank you for your information on security about SQL injections. I just needed an anwser which was more than funny. The SQL Connection string was wrong. And its my bad that i forgot to mention that this error occurs only on computers which have low-access accounts in our domain. Now i've fixed this and it works. HopingToCode was right. I should check the connection string. Which i did today. Thank you both for your time.
Regards, Matjaž