Hello,
Am getting "String or binary data would be truncated. The statement has been terminated " error msg while trying to insert a row in Sql Db.
Any suggestions will be most welcome..
thanks
Am getting "String or binary data would be truncated. The statement has been terminated " error msg while trying to insert a row in Sql Db.
Any suggestions will be most welcome..
thanks
Code:
Public Sub InsertData()
Try
Dim myAppName As String = "myAppName"
Dim myADName As String = "myADName"
Dim myStatus As String = "myStatus"
Using myConn As New SqlConnection
myConn.ConnectionString = myConnStr
myConn.Open()
Using myCmd As New SqlCommand
myCmd.Connection = myConn
Dim myQuery As String = "INSERT INTO " & myTableName &
"(" &
clsConst.AppName & "," &
clsConst.AdUserName & "," &
clsConst.RStatus &
") " &
"VALUES (" &
"'" & myAppName & "', " &
"'" & myADName & "', " &
"'" & myStatus & "'" &
")"
myCmd.CommandText = myQuery
myCmd.ExecuteNonQuery()
myConn.Close()
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub