Re: SQL insert
- From: "Chris" <NoSpam@xxxxxxxxxx>
- Date: Wed, 27 Apr 2005 20:15:29 -0400
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
>
>
.
- References:
- SQL insert
- From: Michael Persaud
- SQL insert
- Prev by Date: Re: Installing my application - Publisher cannot be verified
- Next by Date: Re: Newb Question: Displaying comma delimted text in different text bo
- Previous by thread: SQL insert
- Next by thread: Re: Icons importing from DLL or EXE
- Index(es):
Relevant Pages
|