remote access to sql server 2000 by c#
-
-
hi I want to connect to a sqlserver instance on another computer in the workgroup network. my program is win application with c# VS.NET 2008 and SQL Server 2000. what settings are needed for my sqlserver instance and my application? can you help me?
H.R
You need to create a Login on the sql server, apply permissions to it (Server roles, User Mapping, etc) and then in your application create a connection string for that server, e.g.
string ConnectionStr = "data source=FriendsServerName;initial catalog=TheDataBase;User ID=YourLogin;Password=12345";
Using that connection string connect to your friend's sql server. That should do the trick. It does on SQL Server 2005 anyway.
var question = (_2b || !(_2b));
-
You need to create a Login on the sql server, apply permissions to it (Server roles, User Mapping, etc) and then in your application create a connection string for that server, e.g.
string ConnectionStr = "data source=FriendsServerName;initial catalog=TheDataBase;User ID=YourLogin;Password=12345";
Using that connection string connect to your friend's sql server. That should do the trick. It does on SQL Server 2005 anyway.
var question = (_2b || !(_2b));
thanks, I did them but I could not to connect. ---------------------------------- my application: VS.NET 2008-C# my DB: SQL Server 2000 Personal Edition my OS: Win XP Profesional sp3 ---------------------------------- I have done these steps: 1. in target sql server instance: Enterprise Manager -> server -> right click -> Properties -> Connections tab -> tick: -allow other sql servers to connect remotely to this sql server using RPC -enforce distributed transactions 2. in target sql server instance: Enterprise Manager -> server -> right click -> Properties -> General tab -> Network Configuration... button -> enabling TCP/IP 3. in target sql server instance: Enterprise Manager -> server -> right click -> Properties -> Security tab -> Authentication -> SQL Server and Windows 4. I created a New Login in target sql server instance: Name=admin , Password=1001 , SQL Server Authentication , Database=Exam 5. my SqlConnection in application: "Server=192.168.0.205\\MYSQLSRV; Initial Catalog=Exam; Integrated Security=False; Persist Security Info=False; User ID=admin;Password=1001"; 6. I removed anti virus softwares and turned off Windows Firewall. 7. I tested both of my computers to ping to another But yet I have an error: an error was occured while establishing a connection to the server. when connecting to sql server 2005, this failure may be caused by the fact under the default settings sql server dose not allow remote connections. (provider:sql network interfaces, error:26-error locating server/instance specified) ---------------------------------- can any one help me ?
H.R
-
thanks, I did them but I could not to connect. ---------------------------------- my application: VS.NET 2008-C# my DB: SQL Server 2000 Personal Edition my OS: Win XP Profesional sp3 ---------------------------------- I have done these steps: 1. in target sql server instance: Enterprise Manager -> server -> right click -> Properties -> Connections tab -> tick: -allow other sql servers to connect remotely to this sql server using RPC -enforce distributed transactions 2. in target sql server instance: Enterprise Manager -> server -> right click -> Properties -> General tab -> Network Configuration... button -> enabling TCP/IP 3. in target sql server instance: Enterprise Manager -> server -> right click -> Properties -> Security tab -> Authentication -> SQL Server and Windows 4. I created a New Login in target sql server instance: Name=admin , Password=1001 , SQL Server Authentication , Database=Exam 5. my SqlConnection in application: "Server=192.168.0.205\\MYSQLSRV; Initial Catalog=Exam; Integrated Security=False; Persist Security Info=False; User ID=admin;Password=1001"; 6. I removed anti virus softwares and turned off Windows Firewall. 7. I tested both of my computers to ping to another But yet I have an error: an error was occured while establishing a connection to the server. when connecting to sql server 2005, this failure may be caused by the fact under the default settings sql server dose not allow remote connections. (provider:sql network interfaces, error:26-error locating server/instance specified) ---------------------------------- can any one help me ?
H.R
Erm, it seems fine, except:
H.R wrote:
5. my SqlConnection in application: "Server=192.168.0.205\\MYSQLSRV; Initial Catalog=Exam; Integrated Security=False; Persist Security Info=False; User ID=admin;Password=1001";
Well, that should be your connection string, not the actual connection, as in:
private void ConnectToDb()
{
SqlConnection sqlConn = new SqlConnection("Server=192.168.0.205\\MYSQLSRV; Initial Catalog=Exam; Integrated Security=False; Persist Security Info=False; User ID=admin;Password=1001");sqlConn.Open(); // debug here. If THIS throws an exception, well, i can't help you
sqlConn.Close(); //if it doesn't, you're good to go.
}
Test it like that. If this is how you used it, though, I honestly do not know what is wrong. One more thing... i understand you added a login to the server instance... but DID you actually add a user to the database you want them to use? You'll find a "Users" folder in Databases/YourDb/Security/Users That should help. I think.
var question = (_2b || !(_2b));