Wednesday, March 28, 2012

Network access SQLExpress

I am trying to access a SQLExpress database on another computer on my LAN. Using Windows Authentication. I don't really want to go to Mixed Mode authentication as I understand it involves a registry tweak and creating a new user. I am a novice at this.

Getting the following error on running the connection code below:

SQLException was unhandled "Login failed for user 'D37YKC1S\Guest'."

No doubt it is a security problem but I am not sure how to get around it. Any help appreciated.

Connection code:

Dim conn As New SqlClient.SqlConnection

conn.ConnectionString = "Server=D37YKC1S\SQLEXPRESS;Integrated Security=True;Database=VBNMDATA"

conn.Open()

Tried the following which is my Windows logon on the other computer (blank password) but same error:

conn.ConnectionString = "Server=D37YKC1S\SQLEXPRESS;Integrated Security=True;Database=VBNMDATA; User Id=Geoff; Password="

I have TCP/IP enabled in SQL Express and the firewall is off. I can see the server on the other computer with this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

' Retrieve the enumerator instance and then the data.

Dim instance As SqlDataSourceEnumerator = _

SqlDataSourceEnumerator.Instance

Dim table As System.Data.DataTable = instance.GetDataSources()

' Display the contents of the table.

DisplayData(table)

End Sub

Private Sub DisplayData(ByVal table As DataTable)

For Each row As DataRow In table.Rows

For Each col As DataColumn In table.Columns

MessageBox.Show(col.ColumnName.ToString & " " & row(col).ToString)

Next

Next

End Sub

YOu have to create a new login for a WindowsUser you are connecting with (at this time the Guest user) and give himappropiate permissions on the database. Look for "CREATE LOGIN" in the BOL and additionally for granting rights on the db "CREATE USER) and on the appropiate objects "GRANT".

HTH, Jens Suessmeyer.

|||

Thanks. I installed BOL but it broke SQL Server Management Studio Express CTP so I will download to another machine.

Regards,

GS

|||

You don't have to change registry keys to enable mixed authentication. You can use Management Studio to do this. See instructions at: http://msdn2.microsoft.com/en-us/library/ms188670.aspx.

Could you provide more information about how BOL broke Management Studio? I suggest you also file a bug at http://lab.msdn.microsoft.com/productfeedback/Default.aspx.

Note that Books Online is also available online at: http://msdn2.microsoft.com/en-us/library/ms130214(en-us,SQL.90).aspx.

Thanks
Laurentiu

|||

Thanks again. I have VB Express and SQL Express installed along with Management Studio CTP and all working well. I installed the latest BOL and when trying to run Management Studio nothing at all happens, no error, just a blank screen. I did a search on the forums and this is not an uncommon problem and I assumed MS was aware of it. Uninstalling BOL fixed the issue. I will file a bug report as you suggested.

See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=180792&SiteID=1

Regards,

GS

|||All fixed. I downloaded the latest management Studio CTP and all is well.

No comments:

Post a Comment