Showing posts with label sqlexpress. Show all posts
Showing posts with label sqlexpress. Show all posts

Saturday, February 25, 2012

Remote connection to SQLEXPRESS doesn't work!

Hello,

OK. It is not possible for me to get remote connection to a ssqlexpress database (error 40). I tried everything posted in this forum, MSDN site etc., I used named pipes, TCP/IP ports, disabled Zone Alarm etc. it is just not working. I can coonect the Northwind database using SQL Server Management Studio Express CTP without any problem. And I am trying to learn creating databases, tables, stored procedures etc. by using code samples given on the MSDN site.

In at least two examples given examples somehow try to use remote connections to SQLEXPRESS databases in the local computer in order to study stored procedures. Since remote connection isn't working I have been trying to do same thing by connecting the database directly not over a network. I do not know how to do it. The part of the code that does the connection is below. Please help. I am stuck.

Athena

The following code is from:

http://msdn2.microsoft.com/en-us/library/5181xbwd(VS.80).aspx

the connection string is:

' Initialize constants for connecting to the database

' and displaying a connection error to the user.

Protected Const SqlConnectionString As String = _

"Server=(local);" & _

"DataBase=;" & _

"Integrated Security=SSPI"

the code:

' This routine executes a SQL statement that deletes the database (if it exists)

' and then creates it.

Private Sub CreateDatabase()

Dim sqlStatement As String = _

"IF EXISTS (" & _

"SELECT * " & _

"FROM master..sysdatabases " & _

"WHERE Name = 'HowToDemo')" & vbCrLf & _

"DROP DATABASE HowToDemo" & vbCrLf & _

"CREATE DATABASE HowToDemo"

' Display a status message saying that we're attempting to connect.

' This only needs to be done the very first time a connection is

' attempted. After we've determined that MSDE or SQL Server is

' installed, this message no longer needs to be displayed.

Dim statusForm As New Status()

If Not didPreviouslyConnect Then

statusForm.Show("Connecting to SQL Server")

End If

' Attempt to connect to the SQL server instance.

Try

' The SqlConnection class allows you to communicate with SQL Server.

' The constructor accepts a connection string as an argument. This

' connection string uses Integrated Security, which means that you

' must have a login in SQL Server, or be part of the Administrators

' group for this to work.

Dim connection As New SqlConnection(connectionString)

' A SqlCommand object is used to execute the SQL commands.

Dim cmd As New SqlCommand(sqlStatement, connection)

' Open the connection, execute the command, and close the

' connection. It is more efficient to ExecuteNonQuery when data is

' not being returned.

connection.Open()

cmd.ExecuteNonQuery()

connection.Close()

' Data has been successfully submitted.

didPreviouslyConnect = True

didCreateTable = True

statusForm.Close()

' Show the controls for the next step.

lblArrow1.Visible = True

lblStep2.Enabled = True

btnCreateTable.Enabled = True

MsgBox("Database 'HowToDemo' successfully created.", MsgBoxStyle.OKOnly, "Database Creation Status")

Catch sqlExc As SqlException

MsgBox(sqlExc.Message, MsgBoxStyle.OKOnly, "SQL Exception Error")

Catch exc As Exception

' Unable to connect to SQL Server or MSDE

statusForm.Close()

MsgBox(exc.Message, MsgBoxStyle.OKOnly, "Connection failed.")

End Try

End Sub

It looks as though your connection string is missing the instance name of SQLEXPRESS

Server=(local)\SQLEXPRESS

Check our our blog post on troubleshooting this here.

http://blogs.msdn.com/sql_protocols/archive/2006/03/23/558651.aspx

hope this helps,

Brad Sarsfield

|||

Thank you Brad. \SQLEXPRESS solved the problem!

If I solve the "The schema returned by the new query differs from the base query" error when I try to create search queries, I can continue to learn SQLServer programming!

Thanks a lot.

Cem

Remote Connection to SQL Server Express

Hi ,

After reading the SQLexpress weblog , I tried the solution and its still not working

http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx

The client computer gives me this:
Run-Time error -2147217843 (80040e4d)

Log-in failed for user "Kit\Guest"

The connection string in the ADO object in my testing VB6 program is:

my_connection.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=kit;Initial Catalog=AdelaideMushroom;Data Source=KIT\SQLEXPRESS"

I am confused with the error massage as my conncection string is set to connect on UserID = Kit

I am not sure what is gone wrong. The same VB6 program runs perfectly on host machine

I am not sure is there anything to do with SQL Config. Manager's SQL server 2005 service's Log-ON setting:

Log On as - Build-in account: Network service

could Anyone who managed to get remote connection work give me some advise? I am desperate. have read that weblog many times and do not know how to get it work


If you are using WIndows Authentication (with specifying the SSPI part in the connection string) UserId will be ignored, because this is the SQL Server Authentication. The problem that you are experiencing with the Guets user is based on the setting that you probably have Windows XP and enabled the "Simply File and Printer Sharing". You can disable that by navigating through Explorer > Tools > Folder Options > View > Scroll down to the end , deactivate "Simple file sharing"

HTH, jens Suessmeyer.

http://www.sqlserver2005.de|||

Thank you for the answer

I will give it a try when I get back to office tomorrow

|||

Sorry.... but I still get the same error message

I have firewall of host computer disabled, it connects ok with this command

C:\Documents and Settings\Kit>sqlcmd -E -S KIT\SQLEXPRESS,2301

I have simple file sharing disabled, I no longer see any folder visible on my computer (execept printer & fax and Scheduled Tasks) in Map Network drive.

Seems that the client computer has found KIT\SQLEXPRESS but somehow the host computer direct the client computer to Kit\Guest

The host computer User Account shows there are 3 accounts: KIT (myself), SQLDEBUGGER and Guest. I cannot get rid of Guest tough

I've tried turn firewall off on both computer. Same result

Any idea ?