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!