|
-
Dec 24th, 2002, 02:04 PM
#1
Thread Starter
Member
Not trusted with SQL SERVER connection
I try to insert data in to SQL SERVER2000 by VB.NET using ADO.NET.
I am getting error is :
Login failed for user'(null)'.Reason:Not associated with a trusted SQL Server connection
The code is:
Private Sub ButSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButSubmit.Click
Dim myDataSet As DataSet
Dim SQLConn As SqlConnection
SQLConn = New SqlConnection("Data Source=Lynda;Initial Catalog=pubs;")
'SQLConn.Open()
Dim CMDInsert As SqlCommand
Dim strSQL As String = "Insert into addressdb(FirstName,LastName,Address,City,State,Country)Values('" & _
TextBox1.Text & "','" & _
TextBox2.Text & "','" & _
TextBox3.Text & "','" & _
TextBox4.Text & "','" & _
CmbCity.Text & "','" & _
TextBox6.Text & "')"
Try
SQLConn.Open()
CMDInsert = New SqlCommand(strSQL, SQLConn)
CMDInsert.ExecuteNonQuery()
SQLConn.Close()
Catch Ex As Exception
MessageBox.Show(Ex.Message.ToString())
End Try
Pl help me out.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|