SQL INSERT error

  • Thread starter Thread starter Cameron Frasnelly
  • Start date Start date
C

Cameron Frasnelly

Any ideas on why the below doesn't work?

I keep getting this error message????? ---> "Object must implement
IConvertible".

Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSubmit.Click

'CONNECT TO SQL

Dim strConnection As String

strConnection = "Data Source=x.x.x.x,1433;Network Library=DBMSSOCN;Initial
Catalog=Ops1SQL;User ID=dbIN;Password=xxxyyyzzz;"

Dim cn As New SqlConnection(strConnection)

'------INSERT TO BASE Work Order Table

Dim strSQL As String



strSQL = "INSERT INTO tblWorkOrder (FKEYDepartment, Initiator, ReceiveNOW,
Problem)" & _

" VALUES (@Department, @Initiator, @ReceiveNOW, @Problem)"



Dim dbComm As New SqlCommand(strSQL, cn)

dbComm.Parameters.Add("@Department", SqlDbType.Int)

dbComm.Parameters.Add("@Initiator", SqlDbType.Int)

dbComm.Parameters.Add("@ReceiveNOW", SqlDbType.DateTime)

dbComm.Parameters.Add("@Problem", SqlDbType.NText, 16)

dbComm.Parameters("@Department").Value = 8

dbComm.Parameters("@Initiator").Value = CInt(Session("EmployeeKEY"))

dbComm.Parameters("@ReceiveNOW").Value = Now()

dbComm.Parameters("@Problem").Value = Me.txtComments



Dim woKEY As Integer

Try

cn.Open()

woKEY = dbComm.ExecuteScalar()

Catch ex As Exception

Me.txtAccountNumber.Text = ex.Message.ToString

Finally

If cn.State = ConnectionState.Open Then

cn.Close()

End If

Me.txtRespCode.Text = woKEY.ToString

End Try

'------INSERT the sub work order

End Sub
 
dbComm.Parameters("@Problem").Value = Me.txtComments

I think you want: Me.txtComments.Text
 
Back
Top