none
Connection String over LAN RRS feed

  • Question

  • I am using SQL Server 2008. I want to enter data from client to server machine. I have put the following code in form load event

     

     

    Dim conn As SqlConnection

     

    Dim cmd As SqlCommand

    Dim

     

    cmdString As String = "Insert tblTehsil (Tehsil_Code, Tehsil_Name,ContactName) Values (3, 'XYZ Company')"

    conn =

    New SqlConnection("Data Source=192.168.0.16,1433; Network Library=DBMSSOCN; Initial Catalog=CCDP;Integrated Security=True")

     

    cmd =

    New SqlCommand(cmdString, conn)

    conn.Open()

    cmd.ExecuteNonQuery()

    conn.Close()

    MsgBox(

    "Successful")

    But I am receiving the following error

     

    "Login failed. The login is from an untrusted domain and cannot be used with Windows authentication."

    Please help me.

    • Moved by VMazurModerator Wednesday, December 1, 2010 11:39 AM (From:ADO.NET DataSet)
    Tuesday, November 30, 2010 6:59 AM

Answers

  • You're not passing any credentials to sqlcmd.exe. So it's trying to authenticate you using the Windows Login credentials, but you mustn't have your SQL Server setup to accept those credentials... When you were installing it, you would have had to supply a Server Admin password (for the saaccount)

    Whatever username you are using on the "remote" machine must be set up on the "server" machine. So, if you are logged-in to "remote" as "John," there must be a "John" user on the machine that is hosting SQL Server 2008 Express, and unless you are going to provide different credentials, it should have the same password, too.

    Try:

    sqlcmd.exe -U sa -P YOUR_PASSWORD -S ".\SQL2008"
    

     

    • Proposed as answer by mohammad ansari Tuesday, November 30, 2010 10:20 AM
    • Marked as answer by liurong luo Monday, December 6, 2010 10:30 AM
    Tuesday, November 30, 2010 9:49 AM

All replies

  • You're not passing any credentials to sqlcmd.exe. So it's trying to authenticate you using the Windows Login credentials, but you mustn't have your SQL Server setup to accept those credentials... When you were installing it, you would have had to supply a Server Admin password (for the saaccount)

    Whatever username you are using on the "remote" machine must be set up on the "server" machine. So, if you are logged-in to "remote" as "John," there must be a "John" user on the machine that is hosting SQL Server 2008 Express, and unless you are going to provide different credentials, it should have the same password, too.

    Try:

    sqlcmd.exe -U sa -P YOUR_PASSWORD -S ".\SQL2008"
    

     

    • Proposed as answer by mohammad ansari Tuesday, November 30, 2010 10:20 AM
    • Marked as answer by liurong luo Monday, December 6, 2010 10:30 AM
    Tuesday, November 30, 2010 9:49 AM
  • hi,

    create a sqlserver login on your server,

    use a connection string like:

    connectionString="Data source=yourServerIP; Initial catalog=yourDataBaseName; User Id=yourUserName; Password=yourPassWord;"

     


    .Net adventurer

    If (a post answers your question) {please click " Mark As Answer" and "Mark as Helpful" on that post} 

    Tuesday, November 30, 2010 10:20 AM