Hi all, im new to this forum and to VB.net programming, i have some previous experience in c++ but not a significant amount. anyhow...
I am making a program for my auto shop that keeps track of several pieces of information. When im attempting to update my sql server with the input data for a new record on my customers table i am getting this error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: String or binary data would be truncated.
The statement has been terminated.
then under my "autos tab" during debugging it says in red:
+ PhoneText {Text = ""} System.Windows.Forms.TextBox
+ objCmd.Parameters.Item("@PhoneNumber").Value "System.Windows.Forms.TextBox, Text: " {String} Object
i am not certain what this means, i though maybe i was sending the table the wrong data type and tried several different ones to no avail. Here is my code for this particular section
if anyone can shed some light on this or point me towards a better way to do this it would be very much appreciated thanks
I am making a program for my auto shop that keeps track of several pieces of information. When im attempting to update my sql server with the input data for a new record on my customers table i am getting this error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: String or binary data would be truncated.
The statement has been terminated.
then under my "autos tab" during debugging it says in red:
+ PhoneText {Text = ""} System.Windows.Forms.TextBox
+ objCmd.Parameters.Item("@PhoneNumber").Value "System.Windows.Forms.TextBox, Text: " {String} Object
i am not certain what this means, i though maybe i was sending the table the wrong data type and tried several different ones to no avail. Here is my code for this particular section
VB.NET:
Private Sub btnAddCustomer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'cnn.Open()
Dim sSQL As String = "INSERT INTO Customers " & _
"(FirstName, LastName, City, State, Zip, Phone#)" & _
"VALUES (@FirstName, @LastName, @City, @State, @Zip, @PhoneNumber)"
Dim objCmd As New SqlCommand(sSQL, cnn)
objCmd.Parameters.Add("@FirstName", SqlDbType.VarChar)
objCmd.Parameters.Item("@FirstName").Value = FirstNameText.Text.ToString
objCmd.Parameters.Add("@LastName", SqlDbType.VarChar)
objCmd.Parameters.Item("@LastName").Value = LastNameText.Text.ToString
objCmd.Parameters.Add("@City", SqlDbType.VarChar)
objCmd.Parameters.Item("@City").Value = CityText.Text.ToString
objCmd.Parameters.Add("@State", SqlDbType.VarChar)
objCmd.Parameters.Item("@State").Value = StateText.ToString
objCmd.Parameters.Add("@Zip", SqlDbType.VarChar)
objCmd.Parameters.Item("@Zip").Value = ZipText.Text.ToString
objCmd.Parameters.Add("@PhoneNumber", SqlDbType.NChar)
objCmd.Parameters.Item("@PhoneNumber").Value = PhoneText.ToString
objCmd.ExecuteNonQuery()
End Sub
if anyone can shed some light on this or point me towards a better way to do this it would be very much appreciated thanks