String or binary data would be truncated. The statement has been terminated
-
b4 this my prgm running ok.. and i don't do any editing. after a few days, when i try to add data in my databse, there was a msg "runtime error" about my web.config.. my customErrors mode="off", so i change my mode to RemoteOnly.. but another problem come out. it says that "String or binary data would be truncated. The statement has been terminated" and then the source error is : Line 623: cmd.Connection.Open() Line 624: cmd.ExecuteNonQuery() <-- this line r in red colour Line 625: cmd.Connection.Close() this happen after i key in my data and i want to add the data to my database... helpp me pls...
-
b4 this my prgm running ok.. and i don't do any editing. after a few days, when i try to add data in my databse, there was a msg "runtime error" about my web.config.. my customErrors mode="off", so i change my mode to RemoteOnly.. but another problem come out. it says that "String or binary data would be truncated. The statement has been terminated" and then the source error is : Line 623: cmd.Connection.Open() Line 624: cmd.ExecuteNonQuery() <-- this line r in red colour Line 625: cmd.Connection.Close() this happen after i key in my data and i want to add the data to my database... helpp me pls...
I'm sorry, but that's not really all that helpful. This tells me that: 1 - you want to run some SQL 2 - if it ran some data somewhere would be truncated 3 - it throws an error I can't tell you more than that, and I'd hope you could work that out for yourself. I'd say this means one of your parameters is too big, which in turn makes me syspect that you're string mashing SQL, which probably means your code is open to all sorts of attacks. But, hard to say if you are not showing the pertinent code.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
b4 this my prgm running ok.. and i don't do any editing. after a few days, when i try to add data in my databse, there was a msg "runtime error" about my web.config.. my customErrors mode="off", so i change my mode to RemoteOnly.. but another problem come out. it says that "String or binary data would be truncated. The statement has been terminated" and then the source error is : Line 623: cmd.Connection.Open() Line 624: cmd.ExecuteNonQuery() <-- this line r in red colour Line 625: cmd.Connection.Close() this happen after i key in my data and i want to add the data to my database... helpp me pls...
-
b4 this my prgm running ok.. and i don't do any editing. after a few days, when i try to add data in my databse, there was a msg "runtime error" about my web.config.. my customErrors mode="off", so i change my mode to RemoteOnly.. but another problem come out. it says that "String or binary data would be truncated. The statement has been terminated" and then the source error is : Line 623: cmd.Connection.Open() Line 624: cmd.ExecuteNonQuery() <-- this line r in red colour Line 625: cmd.Connection.Close() this happen after i key in my data and i want to add the data to my database... helpp me pls...
this is my coding. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim _kod As String Dim Pemanggil As String Dim Negeri As String Dim run_no As String Pemanggil = TextBox10.Text.Trim Negeri = TextBox4.Text.Trim If Kod.Text.Length > 0 And Nama.Text.Length > 0 And TextBox4.Text.Length > 0 And TextBox10.Text.Length > 0 And No_Tel.Text.Length > 0 And Masalah.Text.Length > 0 And Penyelesaian.Text.Length > 0 And TextBox9.Text.Length > 0 Then Dim myConn As New SqlConnection(ConfigurationSettings.AppSettings("strConn")) Dim MySQL As String = "INSERT INTO Senarai_Log(docNo,Tarikh,Kod_Koop,Nama_Koop,Nama_Koop1,Negeri,Nama,No_Tel,Masalah,Penyelesaian,Tindakan) Values (@docNo,@Tarikh,@Kod_Koop,@Nama_Koop,@Nama_Koop1,@Negeri,@Nama,@No_Tel,@Masalah,@Penyelesaian,@Tindakan)" Dim cmd As SqlCommand = New SqlCommand(MySQL, myConn) cmd.Parameters.Add(New SqlParameter("@Tarikh", SqlDbType.NVarChar, 250)) cmd.Parameters("@Tarikh").Value = System.DateTime.Now.Date cmd.Parameters.Add(New SqlParameter("@Kod_Koop", SqlDbType.NVarChar, 250)) cmd.Parameters("@Kod_Koop").Value = Kod.Text.Trim cmd.Parameters.Add(New SqlParameter("@Nama_Koop", SqlDbType.NVarChar, 250)) cmd.Parameters("@Nama_Koop").Value = Nama.Text.Trim cmd.Parameters.Add(New SqlParameter("@Nama_Koop1", SqlDbType.NVarChar, 250)) cmd.Parameters("@Nama_Koop1").Value = Nama1.Text.Trim cmd.Parameters.Add(New SqlParameter("@Negeri", SqlDbType.NVarChar, 250)) cmd.Parameters("@Negeri").Value = Negeri cmd.Parameters.Add(New SqlParameter("@No_Tel", SqlDbType.Char, 50)) cmd.Parameters("@No_Tel").Value = No_Tel.Text.Trim cmd.Parameters.Add(New SqlParameter("@Masalah", SqlDbType.Char, 250)) cmd.Parameters("@Masalah").Value = Masalah.Text.Trim cmd.Parameters.Add(New SqlParameter("@Penyelesaian", SqlDbType.NVarChar, 250)) cmd.Parameters("@Penyelesaian").Value = Penyelesaian.Text.Trim cmd.Parameters.Add(New SqlParameter("@Tindakan", SqlDbType.Char, 50)) cmd.Parameters("@Tindakan").Value = TextBox9.Text.Trim cmd.Parameters.Add(New SqlParameter("@Nama", SqlDbType.Char, 50)) cmd.Parameters("@Nama").Value = Peman
-
this is my coding. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim _kod As String Dim Pemanggil As String Dim Negeri As String Dim run_no As String Pemanggil = TextBox10.Text.Trim Negeri = TextBox4.Text.Trim If Kod.Text.Length > 0 And Nama.Text.Length > 0 And TextBox4.Text.Length > 0 And TextBox10.Text.Length > 0 And No_Tel.Text.Length > 0 And Masalah.Text.Length > 0 And Penyelesaian.Text.Length > 0 And TextBox9.Text.Length > 0 Then Dim myConn As New SqlConnection(ConfigurationSettings.AppSettings("strConn")) Dim MySQL As String = "INSERT INTO Senarai_Log(docNo,Tarikh,Kod_Koop,Nama_Koop,Nama_Koop1,Negeri,Nama,No_Tel,Masalah,Penyelesaian,Tindakan) Values (@docNo,@Tarikh,@Kod_Koop,@Nama_Koop,@Nama_Koop1,@Negeri,@Nama,@No_Tel,@Masalah,@Penyelesaian,@Tindakan)" Dim cmd As SqlCommand = New SqlCommand(MySQL, myConn) cmd.Parameters.Add(New SqlParameter("@Tarikh", SqlDbType.NVarChar, 250)) cmd.Parameters("@Tarikh").Value = System.DateTime.Now.Date cmd.Parameters.Add(New SqlParameter("@Kod_Koop", SqlDbType.NVarChar, 250)) cmd.Parameters("@Kod_Koop").Value = Kod.Text.Trim cmd.Parameters.Add(New SqlParameter("@Nama_Koop", SqlDbType.NVarChar, 250)) cmd.Parameters("@Nama_Koop").Value = Nama.Text.Trim cmd.Parameters.Add(New SqlParameter("@Nama_Koop1", SqlDbType.NVarChar, 250)) cmd.Parameters("@Nama_Koop1").Value = Nama1.Text.Trim cmd.Parameters.Add(New SqlParameter("@Negeri", SqlDbType.NVarChar, 250)) cmd.Parameters("@Negeri").Value = Negeri cmd.Parameters.Add(New SqlParameter("@No_Tel", SqlDbType.Char, 50)) cmd.Parameters("@No_Tel").Value = No_Tel.Text.Trim cmd.Parameters.Add(New SqlParameter("@Masalah", SqlDbType.Char, 250)) cmd.Parameters("@Masalah").Value = Masalah.Text.Trim cmd.Parameters.Add(New SqlParameter("@Penyelesaian", SqlDbType.NVarChar, 250)) cmd.Parameters("@Penyelesaian").Value = Penyelesaian.Text.Trim cmd.Parameters.Add(New SqlParameter("@Tindakan", SqlDbType.Char, 50)) cmd.Parameters("@Tindakan").Value = TextBox9.Text.Trim cmd.Parameters.Add(New SqlParameter("@Nama", SqlDbType.Char, 50)) cmd.Parameters("@Nama").Value = Peman
-
this is my coding. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim _kod As String Dim Pemanggil As String Dim Negeri As String Dim run_no As String Pemanggil = TextBox10.Text.Trim Negeri = TextBox4.Text.Trim If Kod.Text.Length > 0 And Nama.Text.Length > 0 And TextBox4.Text.Length > 0 And TextBox10.Text.Length > 0 And No_Tel.Text.Length > 0 And Masalah.Text.Length > 0 And Penyelesaian.Text.Length > 0 And TextBox9.Text.Length > 0 Then Dim myConn As New SqlConnection(ConfigurationSettings.AppSettings("strConn")) Dim MySQL As String = "INSERT INTO Senarai_Log(docNo,Tarikh,Kod_Koop,Nama_Koop,Nama_Koop1,Negeri,Nama,No_Tel,Masalah,Penyelesaian,Tindakan) Values (@docNo,@Tarikh,@Kod_Koop,@Nama_Koop,@Nama_Koop1,@Negeri,@Nama,@No_Tel,@Masalah,@Penyelesaian,@Tindakan)" Dim cmd As SqlCommand = New SqlCommand(MySQL, myConn) cmd.Parameters.Add(New SqlParameter("@Tarikh", SqlDbType.NVarChar, 250)) cmd.Parameters("@Tarikh").Value = System.DateTime.Now.Date cmd.Parameters.Add(New SqlParameter("@Kod_Koop", SqlDbType.NVarChar, 250)) cmd.Parameters("@Kod_Koop").Value = Kod.Text.Trim cmd.Parameters.Add(New SqlParameter("@Nama_Koop", SqlDbType.NVarChar, 250)) cmd.Parameters("@Nama_Koop").Value = Nama.Text.Trim cmd.Parameters.Add(New SqlParameter("@Nama_Koop1", SqlDbType.NVarChar, 250)) cmd.Parameters("@Nama_Koop1").Value = Nama1.Text.Trim cmd.Parameters.Add(New SqlParameter("@Negeri", SqlDbType.NVarChar, 250)) cmd.Parameters("@Negeri").Value = Negeri cmd.Parameters.Add(New SqlParameter("@No_Tel", SqlDbType.Char, 50)) cmd.Parameters("@No_Tel").Value = No_Tel.Text.Trim cmd.Parameters.Add(New SqlParameter("@Masalah", SqlDbType.Char, 250)) cmd.Parameters("@Masalah").Value = Masalah.Text.Trim cmd.Parameters.Add(New SqlParameter("@Penyelesaian", SqlDbType.NVarChar, 250)) cmd.Parameters("@Penyelesaian").Value = Penyelesaian.Text.Trim cmd.Parameters.Add(New SqlParameter("@Tindakan", SqlDbType.Char, 50)) cmd.Parameters("@Tindakan").Value = TextBox9.Text.Trim cmd.Parameters.Add(New SqlParameter("@Nama", SqlDbType.Char, 50)) cmd.Parameters("@Nama").Value = Peman
I never specify lengths like this, I just add the parameters directly and let the framework, work it out for me. I would suggest that it would be great for you to do some study, you may want to read the article I link to in my sig, it explains how best to get help when you have an error message you cannot understand.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I never specify lengths like this, I just add the parameters directly and let the framework, work it out for me. I would suggest that it would be great for you to do some study, you may want to read the article I link to in my sig, it explains how best to get help when you have an error message you cannot understand.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )