Case :
I'm creating a desktop application with VB.NET (Windows Forms), and using SQL Server 2008 Express for its database.
Problem :
I want to create a client-server application, it means I just need 1 database on the server.
I have a computer and a laptop. I set my laptop's IP to 192.168.1.1 and my computer's IP to 192.168.1.2.
Now I place the database on my computer, the database name is db_transportasi.
Problem is, how to connect my computer's database from my laptop?
Specification :
I'm using this string below for my connection :
Data Source=ARVID-THEODORUS\SQLEXPRESS;Initial Catalog=DB_TRANSPORTASI;Integrated Security=True
I already setup my SQL Configuration Manager, enabled the TCP/IP, switch to the IP Addresses tab and set the IPAII Port Properties to 2301
I turned off my firewall so I don't have to set any exception.
Here is the SQL Server SS :
Question :
How to connect to my computer's database from my laptop?
Could you show me the example for my laptop VB.NET Connection String?
Thanks before.
There you go:
"Server=192.168.1.2,1433;Initial Catalog=DB_TRANSPORTASI;Integrated Security=True"
ConnectionStrings.com is a good resource for connection strings for many different databases.
try this link:
http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/
connection string:
"Network Library=DBMSSOCN; Data Source=xxx.xxx.xxx.xxx,1433;" & _
"Initial Catalog=mySQLServerDBName; User ID=myUsername;" & _
"Password=myPassword"
Try this page. A whole list of different ways.
http://www.connectionstrings.com/sql-server-2008
Ensure that you start up the "SQL Server Browser" service in SQL server configuration manager.
Related
I'm doing research on how to integrate users or groups in Active Directory to SQL Server so that users can simply login to Windows and use the application (the connection is thru Windows Authentication).
What I did so far:
Install Windows Server 2008 R2 on a machine with the name "TheServerMachine"
Set "TheServerMachine" as Active Directory domain "MyDomain" controller
Add user User1 to active directory.
Add group Group1 to active directory. (Global, Security)
Add User1 to Group1
Install SQL Server 2008 Express, "SQLEXPRESS" as instance, on "TheServerMachine"
Set server to allow remote connection
The SQL server is in firewal exception
TCP/IP protocol is enabled for the SQL service
Setup the database "MyDatabase"
Add role "MyRules"
Add "MyDomain/Group1" to Login (the dialog box recognizes the group and the domain) with the default database "MyDatabase"
Add user "Group1Users" to "MyDatabase", added a role "MyRules" and set the login I have created.
Add a client machine with the name "Client1" to "MyDomain".
Done!
My problem is, I can't access the SQL server in my client PC which is successfully logged in as "User1" in windows. Using these server path in my ConnectionString, it says that server may not allow remote connection, or the server path may be invalid.
"\\TheServerMachine\SQLEXPRESS"
"\\MyDomain\SQLEXPRESS"
"\\192.168.0.1\SQLEXPRESS"
"TheServerMachine\SQLEXPRESS"
"MyDomain\SQLEXPRESS"
"192.168.0.1\SQLEXPRESS"
Note: My connection string is set "Integrated Security=True".
Do you think it has something to do with my path?
Is it because the domain and SQL server is on the same machine? (I don't think so)
Did I miss some configuration to Domain? Active Directory? SQL Server?
Should I use "SSPI" instead of "True" in "Integrated Security"?
Thanks in advance!
If your TCP/IP protocol is enabled, also make sure that SQL Server Browser service is enabled and started (and set it to automatic if you will be receiving connections from clients).
The SQL Server Browser is use for dynamic port allocation for named instances (in this case SQLEXPRESS is a named instance) and reaches out over port 1434. Also ensure that port 1433 and port 1434 are open.
Edit: Ensure that you are working with SQL Server services through the SQL Server Configuration Manager (SSCM), as the Windows Service Manager/Console snap-in doesn't have the added functionality that SQL Server services require.
First thing that jumps to mind is that SQLExpress isn't configured for remote connections out of the box. Instructions on how to do that
You might run into some other issues after this but try the things in that article first.
And indeed you did already establish that you configured SQLExpress for remote connections. Next item that popped out was your uncertainty on connection string with Integrated security true vs SSPI. What does the current connection string look like? I would assume something like
Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf
This SO question has plenty of troubleshooting and a wonderful title SQL Express connection string hell ASP.Net
I have installed Oracle 10g in one of my office's computer. I want to keep this as database server. I am developing a .net project which will communicate with the database server from client machine and from the server machine. I success to communicate with oracle from server machine but not from client machine using the .net project. The connection code is as follows:
Public OraConn As ADODB.Connection
OraConn = New ADODB.Connection
OraConn.Provider = "OraOLEDB.Oracle"
OraConn.ConnectionString = "Data Source=<my_database_name>;User ID=<my_user>;Password=<my_pass>;"
OraConn.Open()
Please tell me step by step procedures how can I connect to my server database from my .net client program resides on client machine ?
Thanks in Advance.
My first thought is to try and ping the port of the db in your server (if you are using windows you can use "telnet ", see that you aren't blocked by any firewall rules in you server.
my second one is "Data Source="
if all fails, try reading this:
http://www.oracle.com/technology/pub/articles/cook_dotnet.html
i m creating an application, inwhich client has to acces a database stored in a remote location connnected through a live ip. how can i connect simply with a database server placed in LAN. both using sql server 2005 express edition. please refer me or help me on this
Set in your connection string IP address of remote server.
E.g.
"Data source=192.168.0.13; Database=MyDb;User ID=my_user;password=12345"
where 192.168.0.13 is your remote server IP and MyDb is your database name.
Also, make sure to configure your SQL Server Express to allow remote connections! Those are disabled by default after installation.
Check out the SQL Server Surface Configuration tool (if I'm not mistaken) to configure these settings.
Marc
This not about programming. You have forward the port which Sql Server uses on modem.
I have a remote server that has win2003 installed
I can connect to the machine using remote desktop and am succesfully hosting a web app on the server
I need to connect to the SQL server on that machine using a sql compare tool that I have.
What are the steps that I need to take to be able to connect to the SQL server given that all I have is the IP address to the machine and admin login credentials
if you are trying to remotely connect to sql server using ssms or another client on a different machine, you need to do the following:
open up sqlservr on server firewall
open up sqlbrowsr on server firewall
be concerned about security - if you can rdp/connect to sql w/o vpn, then so can other people - so you better make sure you have hardened environment and very strong passwords.
Depending on the specific access technology, different syntaxes for connection strings are needed. For the .NET provider, the syntax allows for passing server addresses.
Here's a sample connection ADO.net connection.
imports System.Data.SqlConnection
...
dim cn as new SqlConnection()
cn.connectionString = "Server=192.168.1.200;Database=mydbName;user id=notSA;password=C0mp!3xPVVD"
cn.open()
...
'Do cool stuff
...
cn.close()
Open up port TCP 1433 (Sql Server) on the remote server
And for your connection string jus use the IP Address for the Server, instead of using the computer name
You should be able to interchange between computer name and IP address without any problems, because the Computer Name gets turned into an IP Address anyway.
I have a VB script which connects to a local SQL database to retrieve a value. The exact same script runs on about 100 servers, but a few of the servers produce this error:
[DBNETLIB][ConnectionOpen (PreLoginHandshake()).]General network error. Check your network documentation
Here is the code that runs:
Function GetPrimaryServerID
On Error Resume Next
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open "Provider=SQLOLEDB;Data Source=127.0.0.1;Initial Catalog=xxx;User ID=xxx;Password=xxx"
sqlquery = "SELECT ServerID FROM tblSettings"
objRecordSet.Open sqlquery,objConnection
objRecordSet.MoveFirst
GetPrimaryServerID = objRecordSet("ServerID")
objRecordSet.Close
objConnection.Close
End Function
The error occurs on the 5th line when trying to open the connection string. I'm confused as to why this script is working on nearly all servers and failing on only a handful. The database that they connect to is identical on every server in terms of structure, its only the data that changes.
Fixed the problem by doing the following:
Opened SQL Server Configuration Manager and went to Protocols for MSSQLSERVER -> TCP/IP. In the 'IP Addresses' tab, I noticed that IP2 which has address of 127.0.0.1 was active but not enabled. Changed to enabled and restarted SQL services. My VB script now successfully opens the connection to 127.0.0.1.
It could fail if the database is not configured to listen to TCP/IP traffic. The error "Named Pipes Provider, error: 0 - No process is on the other end of the pipe." points in that direction.
You can test that with:
telnet 127.0.0.1 1433
To configure where the server listens, use `SQL Server Network Utility" for SQL Server 2000, or "SQL Server Surface Area Configuration" for SQL Server 2005 and up.
It's not a database error, but a client tools or config error
The failing servers will probably:
have a different level of either SQL Server install /includes service pack)
are configured for Windows Authentication only
have an older MDAC (linked to SQL Service pack, OS Service pack etc)
Edit:
SQL Server SSL Encryption, server side, is described here. And in KB 316898 too
"Server side" requires only a server certificate and all connections are encrypted
"client side" requires client certs and is optional, and only for that client
Certain client libraries (notably MS JDBC) do not support this.
If I've guessed right, you'll have either client or server SSL encryption set based on the server (your script is acting as a client)
a blog entry too
It may also be mismatching calls to WSAStartup and WSACleanup. If you call WSACleanup too often then sockets stop working. And the SQL client will also break - which is usually the case for remote DB servers (as opposed to local instances accessed through named pipes etc.).
Try to disable the WPF and this should solve the problem (Control Panel -> Windows Firewall).
If not, then you can also stop the service for firewall (from Services.msc --> Windows personal firewall)