Re: SQL insert

Tech-Archive recommends: Fix windows errors by optimizing your registry



Look at exception.message. It will give you more details. It would also be
nice to know what line is throwing the exception.

Also:

Dim Reports --> You should declare the type.

CboReportsTo.Text.ToString --> it is a string, no need for ToString

If CboReportsTo.Text.ToString > "" Then --> CboReportsTo.Length > 0

Chris


"Michael Persaud" <jinxpersaud@xxxxxxxxxxx> wrote in message
news:eX6u5a2SFHA.3344@xxxxxxxxxxxxxxxxxxxxxxx
> Hello,
>
> I am trying to insert into a SQL2000 dbase some records
>
> i am havinf some difficulty with the code below:
>
> Dim Reports
>
> If CboReportsTo.Text.ToString > "" Then
>
> Reports = CboReportsTo.Text.ToString
>
> Else
>
> Reports = ""
>
> End If
>
> Dim str As String = "insert into
> Jobtitle(JobTitle,JobDescription,ReportsTo)
> values('" _
>
> & txtTitle.Text & "','" & txtDescription.Text & "','" & Reports & "')"
>
> MsgBox(str)
>
> Dim sqlcom As New SqlCommand(str, sqlcon)
>
> 'sqlcom.CommandText = str
>
> sqlcon.Open()
>
> sqlcom.ExecuteNonQuery() ' this line
>
> sqlcon.Close()
>
>
>
> I set a connection string as follows in the class of the vb form;
>
> Dim strC As String = "integrated security=sspi;Data source=to-is1;initial
> catalog=HRO"
>
> Dim sqlcon As SqlConnection = New SqlConnection(strC)
>
>
>
> I cant get the record inserted; sqlexception, system error
>
>
>
> thanks
>
>
>
> Michael
>
>


.



Relevant Pages

  • Search pattern
    ... Dim strfile As String ... Dim bAddressFound As Boolean ... Dim strCurrentChar As String ...
    (comp.databases.ms-access)
  • Auto Write Name and Merge across
    ... Dim Sheetname01 As String ... Dim WeekName01 As String ...
    (microsoft.public.excel.misc)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Help answer these 70-310 questions
    ... One argument is the string ... Dim output As New StringBuilder ... EmployeeLocations. ... You create a strongly named serviced component. ...
    (microsoft.public.cert.exam.mcsd)