Hi,

I have created a databse using sql database "TestingSQL" using microsoft management studio 2012 and created a simple vb application as a tryout. It works well in my pc and i would be able to access remotely as well. But the problem is, it is only works with my windows credentials and other users are not able to connect via the application eventhough we belong to the same domain. I'm new to sql and could anybody tell me the problem. thanks In advance.

Sql database i've tried both sa and windows authentication but failed. the error i got was

<<<can't open database "TestingSQL" requested by the login. The login failed.
Login failed for user " domain name\user name >>>>>>

below is my coding.

Imports System.Data.SqlClient

Public Class Form1

Private con1 As New SqlConnection("Data Source=ComputerName;Initial Catalog=TestingSQL;Integrated Security=True")
Private da As New SqlDataAdapter("SELECT * From User5600", con1)
Private ds As New DataSet
Private cd As New SqlCommandBuilder
Dim sqlinsert As String
Dim cmd As New SqlCommand


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    da.Fill(ds, "User5600")
    DGV.DataSource = ds.Tables("User5600")
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

    sqlinsert = "INSERT INTO User5600 (InstrumentSN, BayNo)" & "VALUES(@InstrumentSN, @BayNo)"
    cmd = New SqlCommand(sqlinsert, con1)

    cmd.Parameters.Add("@InstrumentSN", SqlDbType.Text).Value = txtInstrumentNo.Text
    cmd.Parameters.Add("@BayNo", SqlDbType.Text).Value = txtBayNo.Text

    con1.Open()
    cmd.ExecuteNonQuery()
    con1.Close()

    MsgBox("updated")

End Sub

First thing would be to check the database permissions on the database to see if it allows other's to connect.

With SQL you can use all domain authenticated users, or you can set them individually.

Here is an example.

You should not use the "sa" account for database access. You can use it for testing, but it is designed for administrative use.

SqlConnection.ConnectionString Property

If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored and Integrated Security will be used.

If you want to use domain authentication, grant appropriate permissions as Begginnerdev mentioned.

Edited 2 Years Ago by cgeier

This article has been dead for over six months. Start a new discussion instead.