Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 connecting over LAN

Author  Topic 

Asteroid
Starting Member

13 Posts

Posted - 2006-08-29 : 04:23:55

Hi,

I am trying to RUN windows application on one machine and connect/fetch Data from another machine(Running SQL server) in our LAN. I am using C# studio 2.0 and SQL server 2000.

Precisley speaking I am tring to Run the application on one machine and try to fetch the data from another machine. both machines are in our LAN.

But the connection is timed out and I am stucked. please let me know if there may be any solution for that.

My connection string is.

string sMyConString = "data source=xxx.xx.x.xxx;initial catalog=wtl;persist security info=False;user id=xxxx;password=xxxx;";

Any help,
Regards.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-29 : 05:06:05
Which error are you getting? Permission? SQL Server does not exist?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Asteroid
Starting Member

13 Posts

Posted - 2006-08-29 : 05:13:35
Error Dump is as following.


System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadPacket(Int32 bytesExpected)
at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean& marsCapable)
at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-08-29 : 05:27:39
If you go into Visual Studio; My Project; Settings

Here you can name and set a connection string. If you choose "Connection String" from the setting type, click the elypsis on value... choose the server and the database and test the connection... if this is ok you can then use the name of the setting for your connection string instead of the string itslef. IE If you create a string and name it cnnSQL you could just use cnnSQL in your app instead of having to type the connection string.

First thing though is to try the Settings of the Project in VS, and let me know how you get on

when life hands you lemons, ask for tequila and salt
Go to Top of Page

Asteroid
Starting Member

13 Posts

Posted - 2006-08-29 : 07:02:10
Thx peso, I have tried your tip but the error is still like this

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

This error occors when I try to test the connection.


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-29 : 07:07:48
I think you have to post the C# code together with SQL code.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Asteroid
Starting Member

13 Posts

Posted - 2006-08-29 : 07:26:02
quote:
Originally posted by Peso

I think you have to post the C# code together with SQL code.



class Connection
{
static public System.Data.SqlClient.SqlConnection Conn;
public Connection(){ }

public System.Data.SqlClient.SqlConnection ConnectDB()
{

string sMyConString = "data source=xxx.xx.x.xxx;initial catalog=wtl;persist security info=False;user id=sa;password=sa;";

Conn = new SqlConnection(sMyConString);

try
Conn.Open();


catch (Exception ex)
MessageBox.Show(ex.ToString());

}

}

AND IN THE CALLING CLASS


System.Data.SqlClient.SqlConnection con = new SqlConnection();
Connection Connect = new Connection();
mydata = new DataSet();

if (con.State == ConnectionState.Closed)
con = Connect.ConnectDB();
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-08-29 : 08:51:10
I still think you should test the connection from the IDE before messing with your code.

Check the username and password are correct and that the account has the correct permissions.

Start at the bottom and work your way up

edit: I had same problem with an ASP application... it was the account.

when life hands you lemons, ask for tequila and salt
Go to Top of Page

Asteroid
Starting Member

13 Posts

Posted - 2006-08-30 : 11:04:31

Yes I have tried to work out with the IDE(visual studio project settings) but I am facing the same problem.

I don't think so there may be any username or Pass problem. the access rights are fine and it works fine. I have tried the access rights using the SQL client from remote machine it just worked fine.

I am still stuck, where I was.

Any help
Regards
Go to Top of Page
   

- Advertisement -