G
Guest
Hi..can anyone pls help me with the my code.when I execute this code and key in values such as 3 for jobNum and description for jobName, it can be added into the database but when I enter the values such as NP9008 for jobNum and description for jobName, it couldn’t be added into the database..i’m not sure why the jobNum field could only accept integer values when I’ve already set the parameters to varchar.thanks
<WebMethod()> _
Public Function addJob(ByVal jobNum As String, _
ByVal jobName As String) As DataSet
Dim addCommand As SqlCommand
addCommand = New SqlCommand _
("INSERT INTO Jobs" & _
"(JobNumber,JobName)" & _
"VALUES (" & jobNum & ", '" & _
jobName & "')")
ExecuteCommand(addCommand)
addCommand.Parameters.Add("@JobNumber", SqlDbType.VarChar, 15, "JobNumber")
addCommand.Parameters("@JobNumber").Value = jobNum
addCommand.Parameters.Add("@JobName", SqlDbType.VarChar, 50, "JobName")
addCommand.Parameters("@JobName").Value = jobName
Dim ds As DataSet = New DataSet
Dim da As SqlDataAdapter = New SqlDataAdapter(addCommand)
da.Fill(ds, "Jobs")
Return ds
End Function
<WebMethod()> _
Public Function addJob(ByVal jobNum As String, _
ByVal jobName As String) As DataSet
Dim addCommand As SqlCommand
addCommand = New SqlCommand _
("INSERT INTO Jobs" & _
"(JobNumber,JobName)" & _
"VALUES (" & jobNum & ", '" & _
jobName & "')")
ExecuteCommand(addCommand)
addCommand.Parameters.Add("@JobNumber", SqlDbType.VarChar, 15, "JobNumber")
addCommand.Parameters("@JobNumber").Value = jobNum
addCommand.Parameters.Add("@JobName", SqlDbType.VarChar, 50, "JobName")
addCommand.Parameters("@JobName").Value = jobName
Dim ds As DataSet = New DataSet
Dim da As SqlDataAdapter = New SqlDataAdapter(addCommand)
da.Fill(ds, "Jobs")
Return ds
End Function