473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ADO connections on a web form (repost)

Can someone please help with this?

Unfortunately, that did not work.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:uw****************@TK2MSFTNGP11.phx.gbl...
Hi Jeremy,

Please try using 127.0.0.1 instead of (local) in the connection string:

cnTask.ConnectionString="Data Source=127.0.0.1;" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebClient";
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Here is the code. I am using ADO.NET with new connections and
connections strings everytime.

private void BuildEmployeeDetail(int nEmpId)

{

int [] narValues = new int[15] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

string [] sarInitals = new string[15];

LoadInitialLists(narValues, sarInitals);
string sSql = "SELECT T.TaskDesc, C.TaskId, C.Complete, C.Initials " +

"FROM TasksComplete C " +

"JOIN Tasks T ON (C.TaskId = T.TaskId) " +

"WHERE RemovalId = " + nEmpId;

SqlConnection cnEmployee = new SqlConnection();

cnEmployee.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=";

SqlCommand cmdEmployee = new SqlCommand(sSql, cnEmployee);

cnEmployee.Open();

drEmployee = cmdEmployee.ExecuteReader();
int nCnt = 1;
while(drEmployee.Read())

{

// create a row to add to the existing table

TableRow rowTemplate = new TableRow();

if (nCnt % 2 != 0)

rowTemplate.BackColor = System.Drawing.Color.White;

else

rowTemplate.BackColor = System.Drawing.Color.Silver;

// create cells to add to the previously created row

TableCell cellCol1 = new TableCell();

TableCell cellCol2 = new TableCell();

TableCell cellCol3 = new TableCell();

// enter the description into the first cell

FillFirstCell(rowTemplate, cellCol1, drEmployee.GetString(0), nCnt,
drEmployee.GetBoolean(2));
// enter a hidden task id and check box to the second cell

FillSecondCell(rowTemplate, cellCol2, drEmployee.GetBoolean(2), nCnt,
drEmployee.GetInt32(1));
FillThirdCell(rowTemplate, cellCol3, nCnt, narValues, sarInitals,
drEmployee.GetInt32(3));

// add all of the cells in the row to the table
tblDetail.Rows.Add(rowTemplate);
//dlCopyInitials.Dispose();

rowTemplate.Dispose();

cellCol1.Dispose();

cellCol2.Dispose();

cellCol3.Dispose();

nCnt += 1;

}

drEmployee.Close();

cnEmployee.Close();

cnEmployee.Dispose();

}

private void LoadInitialLists(int [] narVals, string [] sarVals)

{

string sSql = "SELECT I.IsId, I.IsInitials FROM jwames.istable I ORDER
BY 2";

SqlConnection cnEmployee = new SqlConnection();

cnEmployee.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=";

SqlCommand cmdEmployee = new SqlCommand(sSql, cnEmployee);

cnEmployee.Open();

drEmployee = cmdEmployee.ExecuteReader();

int nCnt = 0;

while(drEmployee.Read())

{

sarVals[nCnt] = drEmployee.GetString(1);

narVals[nCnt++] = drEmployee.GetInt32(0);

}

drEmployee.Close();

cnEmployee.Close();

cnEmployee.Dispose();

}

private void UpdateTask(int nEmpId, int nTaskId, bool bChecked, int
nInitials)

{

SqlConnection cnTask = new SqlConnection();

cnTask.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebClient";
SqlCommand cmdUpdateTask = new SqlCommand("usp_UpdateTaskCompletion",
cnTask);

cmdUpdateTask.CommandType = CommandType.StoredProcedure;
SqlParameter parTask = cmdUpdateTask.Parameters.Add("@p_TaskId",
SqlDbType.Int);

parTask.Value = nTaskId;

parTask = cmdUpdateTask.Parameters.Add("@p_RemovalId", SqlDbType.Int);

parTask.Value = nEmpId;

parTask = cmdUpdateTask.Parameters.Add("@p_Initials", SqlDbType.Int);

parTask.Value = nInitials;

parTask = cmdUpdateTask.Parameters.Add("@p_Complete", SqlDbType.Bit);

parTask.Value = bChecked;

cnTask.Open();

cmdUpdateTask.ExecuteNonQuery();

cnTask.Close();

cmdUpdateTask.Dispose();

cnTask.Dispose();

}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:OV**************@TK2MSFTNGP11.phx.gbl...
Hi Jeremy,

A piece of code will be nice, also, are you using ADO or ADO.NET ?
IF not these are a few hints,
1- See if you are really using the third connectionstring
2- Try to not reuse any of the previous used object, create new
Connection,
Command objects

Other than that I cannot think of a possible cause of this problem.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a problem with one of connections using the wrong connection string. I have a form that has three late bound sql connections. Each connection
is local to the function that it used in. The problem I am having is that the last connection uses a different username and password to sign in. By the time that the third connection is opened, the other two connections have been opened, closed, and disposed. What is happening is that the third
connection is still using the connection string from the other connections and connecting with the wrong user credentials. This particular connection executes an update command kept in a stored procedure. I do not allow that particular user, the guest account, access to anything that changes data. What could possibly be happening? I do not want to change my security levels to allow this. Please help!


Nov 15 '05 #1
3 1372
HI Jeremy,

I haven't forget about this :)

Two more suggestions:
1- Place a breakpoint after you assign you open your connection and see what
is the connection string, if it's the correct one then the problem may lay
in the SQL server configuration as described on suggestion 2.

I don't see any problem in your code, so now I'm thinking in the SQL server
configuration. Go to the enterprise manager/Security and make sure that
WebClient is using "SQL Server Authentication" and not "Windows
Authentication" then go to "Database Access" tab and see if the User in your
DB (empDB) is the correct one"

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
Can someone please help with this?

Unfortunately, that did not work.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:uw****************@TK2MSFTNGP11.phx.gbl...
Hi Jeremy,

Please try using 127.0.0.1 instead of (local) in the connection string:

cnTask.ConnectionString="Data Source=127.0.0.1;" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebClient";
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Here is the code. I am using ADO.NET with new connections and
connections strings everytime.

private void BuildEmployeeDetail(int nEmpId)

{

int [] narValues = new int[15] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

string [] sarInitals = new string[15];

LoadInitialLists(narValues, sarInitals);
string sSql = "SELECT T.TaskDesc, C.TaskId, C.Complete, C.Initials " +

"FROM TasksComplete C " +

"JOIN Tasks T ON (C.TaskId = T.TaskId) " +

"WHERE RemovalId = " + nEmpId;

SqlConnection cnEmployee = new SqlConnection();

cnEmployee.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=";

SqlCommand cmdEmployee = new SqlCommand(sSql, cnEmployee);

cnEmployee.Open();

drEmployee = cmdEmployee.ExecuteReader();
int nCnt = 1;
while(drEmployee.Read())

{

// create a row to add to the existing table

TableRow rowTemplate = new TableRow();

if (nCnt % 2 != 0)

rowTemplate.BackColor = System.Drawing.Color.White;

else

rowTemplate.BackColor = System.Drawing.Color.Silver;

// create cells to add to the previously created row

TableCell cellCol1 = new TableCell();

TableCell cellCol2 = new TableCell();

TableCell cellCol3 = new TableCell();

// enter the description into the first cell

FillFirstCell(rowTemplate, cellCol1, drEmployee.GetString(0), nCnt,
drEmployee.GetBoolean(2));
// enter a hidden task id and check box to the second cell

FillSecondCell(rowTemplate, cellCol2, drEmployee.GetBoolean(2), nCnt,
drEmployee.GetInt32(1));
FillThirdCell(rowTemplate, cellCol3, nCnt, narValues, sarInitals,
drEmployee.GetInt32(3));

// add all of the cells in the row to the table
tblDetail.Rows.Add(rowTemplate);
//dlCopyInitials.Dispose();

rowTemplate.Dispose();

cellCol1.Dispose();

cellCol2.Dispose();

cellCol3.Dispose();

nCnt += 1;

}

drEmployee.Close();

cnEmployee.Close();

cnEmployee.Dispose();

}

private void LoadInitialLists(int [] narVals, string [] sarVals)

{

string sSql = "SELECT I.IsId, I.IsInitials FROM jwames.istable I ORDER
BY 2";

SqlConnection cnEmployee = new SqlConnection();

cnEmployee.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=";

SqlCommand cmdEmployee = new SqlCommand(sSql, cnEmployee);

cnEmployee.Open();

drEmployee = cmdEmployee.ExecuteReader();

int nCnt = 0;

while(drEmployee.Read())

{

sarVals[nCnt] = drEmployee.GetString(1);

narVals[nCnt++] = drEmployee.GetInt32(0);

}

drEmployee.Close();

cnEmployee.Close();

cnEmployee.Dispose();

}

private void UpdateTask(int nEmpId, int nTaskId, bool bChecked, int
nInitials)

{

SqlConnection cnTask = new SqlConnection();

cnTask.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebClient";
SqlCommand cmdUpdateTask = new SqlCommand("usp_UpdateTaskCompletion",
cnTask);

cmdUpdateTask.CommandType = CommandType.StoredProcedure;
SqlParameter parTask = cmdUpdateTask.Parameters.Add("@p_TaskId",
SqlDbType.Int);

parTask.Value = nTaskId;

parTask = cmdUpdateTask.Parameters.Add("@p_RemovalId", SqlDbType.Int);

parTask.Value = nEmpId;

parTask = cmdUpdateTask.Parameters.Add("@p_Initials", SqlDbType.Int);

parTask.Value = nInitials;

parTask = cmdUpdateTask.Parameters.Add("@p_Complete", SqlDbType.Bit);

parTask.Value = bChecked;

cnTask.Open();

cmdUpdateTask.ExecuteNonQuery();

cnTask.Close();

cmdUpdateTask.Dispose();

cnTask.Dispose();

}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:OV**************@TK2MSFTNGP11.phx.gbl...
Hi Jeremy,

A piece of code will be nice, also, are you using ADO or ADO.NET ?
IF not these are a few hints,
1- See if you are really using the third connectionstring
2- Try to not reuse any of the previous used object, create new
Connection,
Command objects

Other than that I cannot think of a possible cause of this problem.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I have a problem with one of connections using the wrong connection string.
> I have a form that has three late bound sql connections. Each

connection
is
> local to the function that it used in. The problem I am having is that the
> last connection uses a different username and password to sign in.
By the
> time that the third connection is opened, the other two connections have
> been opened, closed, and disposed. What is happening is that the

third > connection is still using the connection string from the other

connections
> and connecting with the wrong user credentials. This particular

connection
> executes an update command kept in a stored procedure. I do not

allow that
> particular user, the guest account, access to anything that changes data.
> What could possibly be happening? I do not want to change my

security levels
> to allow this. Please help!
>
>


Nov 15 '05 #2
1- The information is coming back correct in the debug window for the
connection string.
2- The user is using sql authentication and it is setup with access to the
databases.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%2******************@TK2MSFTNGP12.phx.gbl...
HI Jeremy,

I haven't forget about this :)

Two more suggestions:
1- Place a breakpoint after you assign you open your connection and see what
is the connection string, if it's the correct one then the problem may lay
in the SQL server configuration as described on suggestion 2.

I don't see any problem in your code, so now I'm thinking in the SQL server
configuration. Go to the enterprise manager/Security and make sure that
WebClient is using "SQL Server Authentication" and not "Windows
Authentication" then go to "Database Access" tab and see if the User in your
DB (empDB) is the correct one"

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
Can someone please help with this?

Unfortunately, that did not work.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:uw****************@TK2MSFTNGP11.phx.gbl...
Hi Jeremy,

Please try using 127.0.0.1 instead of (local) in the connection string:

cnTask.ConnectionString="Data Source=127.0.0.1;" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebClient";
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Here is the code. I am using ADO.NET with new connections and
connections strings everytime.

private void BuildEmployeeDetail(int nEmpId)

{

int [] narValues = new int[15] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

string [] sarInitals = new string[15];

LoadInitialLists(narValues, sarInitals);
string sSql = "SELECT T.TaskDesc, C.TaskId, C.Complete, C.Initials " +

"FROM TasksComplete C " +

"JOIN Tasks T ON (C.TaskId = T.TaskId) " +

"WHERE RemovalId = " + nEmpId;

SqlConnection cnEmployee = new SqlConnection();

cnEmployee.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=";

SqlCommand cmdEmployee = new SqlCommand(sSql, cnEmployee);

cnEmployee.Open();

drEmployee = cmdEmployee.ExecuteReader();
int nCnt = 1;
while(drEmployee.Read())

{

// create a row to add to the existing table

TableRow rowTemplate = new TableRow();

if (nCnt % 2 != 0)

rowTemplate.BackColor = System.Drawing.Color.White;

else

rowTemplate.BackColor = System.Drawing.Color.Silver;

// create cells to add to the previously created row

TableCell cellCol1 = new TableCell();

TableCell cellCol2 = new TableCell();

TableCell cellCol3 = new TableCell();

// enter the description into the first cell

FillFirstCell(rowTemplate, cellCol1, drEmployee.GetString(0), nCnt,
drEmployee.GetBoolean(2));
// enter a hidden task id and check box to the second cell

FillSecondCell(rowTemplate, cellCol2, drEmployee.GetBoolean(2), nCnt,
drEmployee.GetInt32(1));
FillThirdCell(rowTemplate, cellCol3, nCnt, narValues, sarInitals,
drEmployee.GetInt32(3));

// add all of the cells in the row to the table
tblDetail.Rows.Add(rowTemplate);
//dlCopyInitials.Dispose();

rowTemplate.Dispose();

cellCol1.Dispose();

cellCol2.Dispose();

cellCol3.Dispose();

nCnt += 1;

}

drEmployee.Close();

cnEmployee.Close();

cnEmployee.Dispose();

}

private void LoadInitialLists(int [] narVals, string [] sarVals)

{

string sSql = "SELECT I.IsId, I.IsInitials FROM jwames.istable I ORDER
BY 2";

SqlConnection cnEmployee = new SqlConnection();

cnEmployee.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=";

SqlCommand cmdEmployee = new SqlCommand(sSql, cnEmployee);

cnEmployee.Open();

drEmployee = cmdEmployee.ExecuteReader();

int nCnt = 0;

while(drEmployee.Read())

{

sarVals[nCnt] = drEmployee.GetString(1);

narVals[nCnt++] = drEmployee.GetInt32(0);

}

drEmployee.Close();

cnEmployee.Close();

cnEmployee.Dispose();

}

private void UpdateTask(int nEmpId, int nTaskId, bool bChecked, int
nInitials)

{

SqlConnection cnTask = new SqlConnection();

cnTask.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebClient";
SqlCommand cmdUpdateTask = new SqlCommand("usp_UpdateTaskCompletion",
cnTask);

cmdUpdateTask.CommandType = CommandType.StoredProcedure;
SqlParameter parTask = cmdUpdateTask.Parameters.Add("@p_TaskId",
SqlDbType.Int);

parTask.Value = nTaskId;

parTask = cmdUpdateTask.Parameters.Add("@p_RemovalId", SqlDbType.Int);

parTask.Value = nEmpId;

parTask = cmdUpdateTask.Parameters.Add("@p_Initials", SqlDbType.Int);

parTask.Value = nInitials;

parTask = cmdUpdateTask.Parameters.Add("@p_Complete", SqlDbType.Bit);

parTask.Value = bChecked;

cnTask.Open();

cmdUpdateTask.ExecuteNonQuery();

cnTask.Close();

cmdUpdateTask.Dispose();

cnTask.Dispose();

}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:OV**************@TK2MSFTNGP11.phx.gbl...
Hi Jeremy,

A piece of code will be nice, also, are you using ADO or ADO.NET ?
IF not these are a few hints,
1- See if you are really using the third connectionstring
2- Try to not reuse any of the previous used object, create new
Connection,
Command objects

Other than that I cannot think of a possible cause of this problem.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I have a problem with one of connections using the wrong connection string.
> I have a form that has three late bound sql connections. Each

connection
is
> local to the function that it used in. The problem I am having is that the
> last connection uses a different username and password to sign in.
By the
> time that the third connection is opened, the other two connections have
> been opened, closed, and disposed. What is happening is that the

third > connection is still using the connection string from the other

connections
> and connecting with the wrong user credentials. This particular

connection
> executes an update command kept in a stored procedure. I do not

allow that
> particular user, the guest account, access to anything that changes data.
> What could possibly be happening? I do not want to change my

security levels
> to allow this. Please help!
>
>



Nov 15 '05 #3
What happens if you try "host=127.0.0.1; database=EmpDB;
user=WebClient; password=WebClient"?

I really wish the connection string didn't allow so many
syntaxes...

JER
-----Original Message-----
Can someone please help with this?

Unfortunately, that did not work.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>wrote in message news:uwMY% 23***********@TK2MSFTNGP11.phx.gbl... Hi Jeremy,

Please try using 127.0.0.1 instead of (local) in the connection string:
cnTask.ConnectionString="Data Source=127.0.0.1;" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebClient";
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Here is the code. I am using ADO.NET with new connections andconnections strings everytime.

private void BuildEmployeeDetail(int nEmpId)

{

int [] narValues = new int[15] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
string [] sarInitals = new string[15];

LoadInitialLists(narValues, sarInitals);
string sSql = "SELECT T.TaskDesc, C.TaskId, C.Complete, C.Initials " +
"FROM TasksComplete C " +

"JOIN Tasks T ON (C.TaskId = T.TaskId) " +

"WHERE RemovalId = " + nEmpId;

SqlConnection cnEmployee = new SqlConnection();

cnEmployee.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=";

SqlCommand cmdEmployee = new SqlCommand(sSql, cnEmployee);
cnEmployee.Open();

drEmployee = cmdEmployee.ExecuteReader();
int nCnt = 1;
while(drEmployee.Read())

{

// create a row to add to the existing table

TableRow rowTemplate = new TableRow();

if (nCnt % 2 != 0)

rowTemplate.BackColor = System.Drawing.Color.White;

else

rowTemplate.BackColor = System.Drawing.Color.Silver;

// create cells to add to the previously created row

TableCell cellCol1 = new TableCell();

TableCell cellCol2 = new TableCell();

TableCell cellCol3 = new TableCell();

// enter the description into the first cell

FillFirstCell(rowTemplate, cellCol1, drEmployee.GetString(0), nCnt,drEmployee.GetBoolean(2));
// enter a hidden task id and check box to the second cell
FillSecondCell(rowTemplate, cellCol2, drEmployee.GetBoolean(2), nCnt,drEmployee.GetInt32(1));
FillThirdCell(rowTemplate, cellCol3, nCnt, narValues, sarInitals,drEmployee.GetInt32(3));

// add all of the cells in the row to the table
tblDetail.Rows.Add(rowTemplate);
//dlCopyInitials.Dispose();

rowTemplate.Dispose();

cellCol1.Dispose();

cellCol2.Dispose();

cellCol3.Dispose();

nCnt += 1;

}

drEmployee.Close();

cnEmployee.Close();

cnEmployee.Dispose();

}

private void LoadInitialLists(int [] narVals, string [] sarVals)
{

string sSql = "SELECT I.IsId, I.IsInitials FROM jwames.istable I ORDERBY 2";

SqlConnection cnEmployee = new SqlConnection();

cnEmployee.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=";

SqlCommand cmdEmployee = new SqlCommand(sSql, cnEmployee);
cnEmployee.Open();

drEmployee = cmdEmployee.ExecuteReader();

int nCnt = 0;

while(drEmployee.Read())

{

sarVals[nCnt] = drEmployee.GetString(1);

narVals[nCnt++] = drEmployee.GetInt32(0);

}

drEmployee.Close();

cnEmployee.Close();

cnEmployee.Dispose();

}

private void UpdateTask(int nEmpId, int nTaskId, bool bChecked, intnInitials)

{

SqlConnection cnTask = new SqlConnection();

cnTask.ConnectionString="Data Source=(local);" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebClient";
SqlCommand cmdUpdateTask = new SqlCommand ("usp_UpdateTaskCompletion",cnTask);

cmdUpdateTask.CommandType = CommandType.StoredProcedure;

SqlParameter parTask = cmdUpdateTask.Parameters.Add ("@p_TaskId",SqlDbType.Int);

parTask.Value = nTaskId;

parTask = cmdUpdateTask.Parameters.Add ("@p_RemovalId", SqlDbType.Int);
parTask.Value = nEmpId;

parTask = cmdUpdateTask.Parameters.Add ("@p_Initials", SqlDbType.Int);
parTask.Value = nInitials;

parTask = cmdUpdateTask.Parameters.Add ("@p_Complete", SqlDbType.Bit);
parTask.Value = bChecked;

cnTask.Open();

cmdUpdateTask.ExecuteNonQuery();

cnTask.Close();

cmdUpdateTask.Dispose();

cnTask.Dispose();

}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>wrote in message news:OV**************@TK2MSFTNGP11.phx.gbl... Hi Jeremy,

A piece of code will be nice, also, are you using ADO or ADO.NET ? IF not these are a few hints,
1- See if you are really using the third connectionstring 2- Try to not reuse any of the previous used object, create newConnection,
Command objects

Other than that I cannot think of a possible cause of this problem.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I have a problem with one of connections using the wrong connection
string.
> I have a form that has three late bound sql
connections. Eachconnection
is
> local to the function that it used in. The problem
I am having is thatthe
> last connection uses a different username and
password to sign in. Bythe
> time that the third connection is opened, the
other two connectionshave
> been opened, closed, and disposed. What is
happening is that the third > connection is still using the connection string

from the otherconnections
> and connecting with the wrong user credentials.
This particularconnection
> executes an update command kept in a stored
procedure. I do not allowthat
> particular user, the guest account, access to
anything that changesdata.
> What could possibly be happening? I do not want to
change my security levels
> to allow this. Please help!
>
>


.

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: YesBalala | last post by:
I am using CGI.pm, and getting the parameters similiar to the followings, use CGI::Carp qw(fatalsToBrowser); use CGI qw(:all); : my $task = param('task'); my $username= param('username'); ...
4
by: Jeremy Ames | last post by:
I have a problem with one of connections using the wrong connection string. I have a form that has three late bound sql connections. Each connection is local to the function that it used in. The...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
17
by: Peter Proost | last post by:
Hi Group, I've got an interesting problem, I don't know if this is the right group but I think so because everything I've read about it so far says it's a .net problem. Here's the problem, we're...
45
by: Arno R | last post by:
Hi all, I am about to distribute an A97-runtime app. which will be used on a LAN by approx. 30 users. The network is pretty good, but there are a few managers who have wireless laptops... Of...
2
by: Elliot Rodriguez | last post by:
I have a form that contains a mix of dynamic controls and declared controls. All of them are intrinsic .NET controls. Several functions within the page use Request.Form to query the value of the...
13
by: Schmidty | last post by:
If you do a page reload with $_SERVER will your program lose a mysqli connection upon the reload of the page? Would this code work? I need to know how to carry over a connection between methods as...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
9
by: Greg | last post by:
I'm creating a tcp socket connection from the thread in the c# threadpool. Since the default workers thread is 500, sometimes my program tries to open up 500 different tcp socket connections and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.