Unable to Connect To Sql Server 2000 using .NET 2005 EXPRESS

G

Guest

Can anyone help me with an issue. I have a .net app that tries to connect to
my sql server here on my laptop on my company's network. When I have someone
on the network try the app they get the following message in the errorlog:
*Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding*

I tried connecting through IP and machine name but no success. My Sql Server
agent and Sql Server is running. I can access the data fine locally of
course. Here is the connection string:

private string connstring = "pwd=<password>;uid=<username>;" +
"database=projectMgr;server=<machinename>";

Here is what I'm using when the user tries to login:

cmd.CommandType = CommandType.Text;
cmd.Connection = sconn;
cmd.CommandText = "SELECT username, upassword, rights FROM " +
"usertable WHERE username = @username AND upassword =
@upassword";
cmd.CommandTimeout = 30000;

SqlParameter sparam = new SqlParameter();
sparam = cmd.Parameters.AddWithValue("@username", user);
sparam.DbType = DbType.String;
sparam.Direction = ParameterDirection.Input;

sparam = cmd.Parameters.AddWithValue("@upassword", upassword);
sparam.DbType = DbType.String;
sparam.Direction = ParameterDirection.Input;
sconn.Open();

mAdapter.SelectCommand = cmd;
mAdapter.Fill(myDataTable);

if (myDataTable.Rows.Count > 0)
{
mFlag = true;
appObject.uClass.urights =
myDataTable.Rows[0]["rights"].ToString();
}
else
{
mFlag = false;
}

I using the timeout method but it's not helping.
 
G

Guest

Thanks for the reply. I found out that the problem was Microsoft Firewall was
blocking port 1433 which is the default port that SQL SERVER uses. When I
placed this exception in my firewall other indivduals were able to access my
records.

Thanks all.
--
TC


RobinS said:
Check www.connectionstrings.com and see if your connection string is valid.

Robin S.
--------------------
Terrance said:
Can anyone help me with an issue. I have a .net app that tries to connect
to
my sql server here on my laptop on my company's network. When I have
someone
on the network try the app they get the following message in the
errorlog:
*Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding*

I tried connecting through IP and machine name but no success. My Sql
Server
agent and Sql Server is running. I can access the data fine locally of
course. Here is the connection string:

private string connstring = "pwd=<password>;uid=<username>;" +
"database=projectMgr;server=<machinename>";

Here is what I'm using when the user tries to login:

cmd.CommandType = CommandType.Text;
cmd.Connection = sconn;
cmd.CommandText = "SELECT username, upassword, rights FROM
" +
"usertable WHERE username = @username AND upassword =
@upassword";
cmd.CommandTimeout = 30000;

SqlParameter sparam = new SqlParameter();
sparam = cmd.Parameters.AddWithValue("@username", user);
sparam.DbType = DbType.String;
sparam.Direction = ParameterDirection.Input;

sparam = cmd.Parameters.AddWithValue("@upassword",
upassword);
sparam.DbType = DbType.String;
sparam.Direction = ParameterDirection.Input;
sconn.Open();

mAdapter.SelectCommand = cmd;
mAdapter.Fill(myDataTable);

if (myDataTable.Rows.Count > 0)
{
mFlag = true;
appObject.uClass.urights =
myDataTable.Rows[0]["rights"].ToString();
}
else
{
mFlag = false;
}

I using the timeout method but it's not helping.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top