473,692 Members | 2,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADO connections on a web form (repost)

Can someone please help with this?

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

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

cnTask.Connecti onString="Data Source=127.0.0. 1;" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

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

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

private void BuildEmployeeDe tail(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];

LoadInitialList s(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.Conn ectionString="D ata Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=" ;

SqlCommand cmdEmployee = new SqlCommand(sSql , cnEmployee);

cnEmployee.Open ();

drEmployee = cmdEmployee.Exe cuteReader();
int nCnt = 1;
while(drEmploye e.Read())

{

// create a row to add to the existing table

TableRow rowTemplate = new TableRow();

if (nCnt % 2 != 0)

rowTemplate.Bac kColor = System.Drawing. Color.White;

else

rowTemplate.Bac kColor = 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(r owTemplate, cellCol1, drEmployee.GetS tring(0), nCnt,
drEmployee.GetB oolean(2));
// enter a hidden task id and check box to the second cell

FillSecondCell( rowTemplate, cellCol2, drEmployee.GetB oolean(2), nCnt,
drEmployee.GetI nt32(1));
FillThirdCell(r owTemplate, cellCol3, nCnt, narValues, sarInitals,
drEmployee.GetI nt32(3));

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

rowTemplate.Dis pose();

cellCol1.Dispos e();

cellCol2.Dispos e();

cellCol3.Dispos e();

nCnt += 1;

}

drEmployee.Clos e();

cnEmployee.Clos e();

cnEmployee.Disp ose();

}

private void LoadInitialList s(int [] narVals, string [] sarVals)

{

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

SqlConnection cnEmployee = new SqlConnection() ;

cnEmployee.Conn ectionString="D ata Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=" ;

SqlCommand cmdEmployee = new SqlCommand(sSql , cnEmployee);

cnEmployee.Open ();

drEmployee = cmdEmployee.Exe cuteReader();

int nCnt = 0;

while(drEmploye e.Read())

{

sarVals[nCnt] = drEmployee.GetS tring(1);

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

}

drEmployee.Clos e();

cnEmployee.Clos e();

cnEmployee.Disp ose();

}

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

{

SqlConnection cnTask = new SqlConnection() ;

cnTask.Connecti onString="Data Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebCl ient";
SqlCommand cmdUpdateTask = new SqlCommand("usp _UpdateTaskComp letion",
cnTask);

cmdUpdateTask.C ommandType = CommandType.Sto redProcedure;
SqlParameter parTask = cmdUpdateTask.P arameters.Add(" @p_TaskId",
SqlDbType.Int);

parTask.Value = nTaskId;

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

parTask.Value = nEmpId;

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

parTask.Value = nInitials;

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

parTask.Value = bChecked;

cnTask.Open();

cmdUpdateTask.E xecuteNonQuery( );

cnTask.Close();

cmdUpdateTask.D ispose();

cnTask.Dispose( );

}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
wrote in message news:OV******** ******@TK2MSFTN GP11.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 connectionstrin g
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******** ********@TK2MSF TNGP10.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 1383
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******** ******@TK2MSFTN GP10.phx.gbl...
Can someone please help with this?

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

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

cnTask.Connecti onString="Data Source=127.0.0. 1;" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

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

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

private void BuildEmployeeDe tail(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];

LoadInitialList s(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.Conn ectionString="D ata Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=" ;

SqlCommand cmdEmployee = new SqlCommand(sSql , cnEmployee);

cnEmployee.Open ();

drEmployee = cmdEmployee.Exe cuteReader();
int nCnt = 1;
while(drEmploye e.Read())

{

// create a row to add to the existing table

TableRow rowTemplate = new TableRow();

if (nCnt % 2 != 0)

rowTemplate.Bac kColor = System.Drawing. Color.White;

else

rowTemplate.Bac kColor = 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(r owTemplate, cellCol1, drEmployee.GetS tring(0), nCnt,
drEmployee.GetB oolean(2));
// enter a hidden task id and check box to the second cell

FillSecondCell( rowTemplate, cellCol2, drEmployee.GetB oolean(2), nCnt,
drEmployee.GetI nt32(1));
FillThirdCell(r owTemplate, cellCol3, nCnt, narValues, sarInitals,
drEmployee.GetI nt32(3));

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

rowTemplate.Dis pose();

cellCol1.Dispos e();

cellCol2.Dispos e();

cellCol3.Dispos e();

nCnt += 1;

}

drEmployee.Clos e();

cnEmployee.Clos e();

cnEmployee.Disp ose();

}

private void LoadInitialList s(int [] narVals, string [] sarVals)

{

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

SqlConnection cnEmployee = new SqlConnection() ;

cnEmployee.Conn ectionString="D ata Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=" ;

SqlCommand cmdEmployee = new SqlCommand(sSql , cnEmployee);

cnEmployee.Open ();

drEmployee = cmdEmployee.Exe cuteReader();

int nCnt = 0;

while(drEmploye e.Read())

{

sarVals[nCnt] = drEmployee.GetS tring(1);

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

}

drEmployee.Clos e();

cnEmployee.Clos e();

cnEmployee.Disp ose();

}

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

{

SqlConnection cnTask = new SqlConnection() ;

cnTask.Connecti onString="Data Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebCl ient";
SqlCommand cmdUpdateTask = new SqlCommand("usp _UpdateTaskComp letion",
cnTask);

cmdUpdateTask.C ommandType = CommandType.Sto redProcedure;
SqlParameter parTask = cmdUpdateTask.P arameters.Add(" @p_TaskId",
SqlDbType.Int);

parTask.Value = nTaskId;

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

parTask.Value = nEmpId;

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

parTask.Value = nInitials;

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

parTask.Value = bChecked;

cnTask.Open();

cmdUpdateTask.E xecuteNonQuery( );

cnTask.Close();

cmdUpdateTask.D ispose();

cnTask.Dispose( );

}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
wrote in message news:OV******** ******@TK2MSFTN GP11.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 connectionstrin g
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******** ********@TK2MSF TNGP10.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.mach in AT dot.state.fl.us > wrote
in message news:%2******** **********@TK2M SFTNGP12.phx.gb l...
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******** ******@TK2MSFTN GP10.phx.gbl...
Can someone please help with this?

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

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

cnTask.Connecti onString="Data Source=127.0.0. 1;" +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

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

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

private void BuildEmployeeDe tail(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];

LoadInitialList s(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.Conn ectionString="D ata Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=" ;

SqlCommand cmdEmployee = new SqlCommand(sSql , cnEmployee);

cnEmployee.Open ();

drEmployee = cmdEmployee.Exe cuteReader();
int nCnt = 1;
while(drEmploye e.Read())

{

// create a row to add to the existing table

TableRow rowTemplate = new TableRow();

if (nCnt % 2 != 0)

rowTemplate.Bac kColor = System.Drawing. Color.White;

else

rowTemplate.Bac kColor = 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(r owTemplate, cellCol1, drEmployee.GetS tring(0), nCnt,
drEmployee.GetB oolean(2));
// enter a hidden task id and check box to the second cell

FillSecondCell( rowTemplate, cellCol2, drEmployee.GetB oolean(2), nCnt,
drEmployee.GetI nt32(1));
FillThirdCell(r owTemplate, cellCol3, nCnt, narValues, sarInitals,
drEmployee.GetI nt32(3));

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

rowTemplate.Dis pose();

cellCol1.Dispos e();

cellCol2.Dispos e();

cellCol3.Dispos e();

nCnt += 1;

}

drEmployee.Clos e();

cnEmployee.Clos e();

cnEmployee.Disp ose();

}

private void LoadInitialList s(int [] narVals, string [] sarVals)

{

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

SqlConnection cnEmployee = new SqlConnection() ;

cnEmployee.Conn ectionString="D ata Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=" ;

SqlCommand cmdEmployee = new SqlCommand(sSql , cnEmployee);

cnEmployee.Open ();

drEmployee = cmdEmployee.Exe cuteReader();

int nCnt = 0;

while(drEmploye e.Read())

{

sarVals[nCnt] = drEmployee.GetS tring(1);

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

}

drEmployee.Clos e();

cnEmployee.Clos e();

cnEmployee.Disp ose();

}

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

{

SqlConnection cnTask = new SqlConnection() ;

cnTask.Connecti onString="Data Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebCl ient";
SqlCommand cmdUpdateTask = new SqlCommand("usp _UpdateTaskComp letion",
cnTask);

cmdUpdateTask.C ommandType = CommandType.Sto redProcedure;
SqlParameter parTask = cmdUpdateTask.P arameters.Add(" @p_TaskId",
SqlDbType.Int);

parTask.Value = nTaskId;

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

parTask.Value = nEmpId;

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

parTask.Value = nInitials;

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

parTask.Value = bChecked;

cnTask.Open();

cmdUpdateTask.E xecuteNonQuery( );

cnTask.Close();

cmdUpdateTask.D ispose();

cnTask.Dispose( );

}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
wrote in message news:OV******** ******@TK2MSFTN GP11.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 connectionstrin g
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******** ********@TK2MSF TNGP10.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=WebCli ent"?

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

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

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

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

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

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

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

private void BuildEmployeeDe tail(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];

LoadInitialList s(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.Conn ectionString="D ata Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=" ;

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

drEmployee = cmdEmployee.Exe cuteReader();
int nCnt = 1;
while(drEmploye e.Read())

{

// create a row to add to the existing table

TableRow rowTemplate = new TableRow();

if (nCnt % 2 != 0)

rowTemplate.Bac kColor = System.Drawing. Color.White;

else

rowTemplate.Bac kColor = 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(r owTemplate, cellCol1, drEmployee.GetS tring(0), nCnt,drEmployee.Get Boolean(2));
// enter a hidden task id and check box to the second cell
FillSecondCell( rowTemplate, cellCol2, drEmployee.GetB oolean(2), nCnt,drEmployee.Get Int32(1));
FillThirdCell(r owTemplate, cellCol3, nCnt, narValues, sarInitals,drEmployee.Get Int32(3));

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

rowTemplate.Dis pose();

cellCol1.Dispos e();

cellCol2.Dispos e();

cellCol3.Dispos e();

nCnt += 1;

}

drEmployee.Clos e();

cnEmployee.Clos e();

cnEmployee.Disp ose();

}

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

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

SqlConnection cnEmployee = new SqlConnection() ;

cnEmployee.Conn ectionString="D ata Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=guest;" +

"Password=" ;

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

drEmployee = cmdEmployee.Exe cuteReader();

int nCnt = 0;

while(drEmploye e.Read())

{

sarVals[nCnt] = drEmployee.GetS tring(1);

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

}

drEmployee.Clos e();

cnEmployee.Clos e();

cnEmployee.Disp ose();

}

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

{

SqlConnection cnTask = new SqlConnection() ;

cnTask.Connecti onString="Data Source=(local); " +

"Initial Catalog=EmpDB;" +

"User ID=WebClient;" +

"Password=WebCl ient";
SqlCommand cmdUpdateTask = new SqlCommand ("usp_UpdateTas kCompletion",cnTask);

cmdUpdateTask.C ommandType = CommandType.Sto redProcedure;

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

parTask.Value = nTaskId;

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

parTask = cmdUpdateTask.P arameters.Add ("@p_Initial s", SqlDbType.Int);
parTask.Value = nInitials;

parTask = cmdUpdateTask.P arameters.Add ("@p_Complet e", SqlDbType.Bit);
parTask.Value = bChecked;

cnTask.Open();

cmdUpdateTask.E xecuteNonQuery( );

cnTask.Close();

cmdUpdateTask.D ispose();

cnTask.Dispose( );

}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >wrote in message news:OV******** ******@TK2MSFTN GP11.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 connectionstrin g 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******** ********@TK2MSF TNGP10.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
3409
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'); Then I have a debug log as the next line. From the debug log, look
4
1412
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 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...
18
2967
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. If you do have any ideas I would really like to hear them. Thanks Colin - 0 - 0 - 0 - I want a glorified popup/context menu on a button that shows only when
17
8439
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 using crystal reports 9 and vb.net and we're using the crystalrepotViewer to show our reports. But every time we open a report the connection to or sql server remains, so if I open 5 forms with the report viewer I've got 5 sleeping connections in...
45
3052
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 course they also want to access the db. I am a bit afraid of possible corruption due to the wireless connections. ==> Do I have to be afraid indeed? If so, what is the best way to deal with this? Should I trace the wireless connections...
2
1584
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 dynamic controls when the page is posted back. I also have a server side function that validates data ensuring it falls within a given range after the post back. If the range is not valid, I am Throw-ing a new Exception object; the validation...
13
3710
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 I am new to OOP? Thanks... Example; ======================================== <?php // webpage $newsignon = new newuser(); logon();
5
3389
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 left, I always see that there are 2 connections open and in "ESTABLISHED" state. Here is the piece of code that I'm using, please tell where I'm doing it wrong. Since this class is being used at many placed in my actual web based application that...
9
24563
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 the connection fails after it reaches certain number of opened tcp connection. I guess it reached the max number of tcp connection available in the operating system. I have Professional Windows XP 2000. So what is the max simultaneous tcp...
0
8608
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8963
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8806
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4324
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4557
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2241
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1959
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.