Results 1 to 3 of 3

Thread: Not trusted with SQL SERVER connection

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    61

    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.

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    You need to either supply a sql server user id and password or use windows integrated authentication (check your permissions..)

    add this to your connection string:

    Code:
    // password may vary..
    "user id=sa; pwd=;

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    61
    It Works Fine.

    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
  •  



Click Here to Expand Forum to Full Width