Writing to a DB

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey guys,

I'm working on a project that has forms authentication implemented with Access 2003. I'm trying to write a page that will allow users to change their password. So far, without success. Here's a look at part of what I have..

if(txtuname == (string)Session["ucode"] && txtoldpass == (string)Session["pword"] && txtoldpassconf == (string)Session["pword"])
{
OleDbConnection Conn2 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\PATH\\users.mdb");
Conn2.Open();


string writepass = "UPDATE tblUsers SET password='" + txtnewpass + "' WHERE username='" + txtuname + "'";
OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);

Conn2.Close();
}

else
Response.Write("Incorrect credentials supplied");

Any help would be much appreciated..Thank you!
 
You did not execute the sql statement. Do this:

OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);
Cmd.ExecuteNonQuery;

chanmm


Edmond Goon said:
Hey guys,

I'm working on a project that has forms authentication implemented with
Access 2003. I'm trying to write a page that will allow users to change
their password. So far, without success. Here's a look at part of what I
have..
if(txtuname == (string)Session["ucode"] && txtoldpass ==
(string)Session["pword"] && txtoldpassconf == (string)Session["pword"])
{
OleDbConnection Conn2 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\PATH\\users.mdb");
Conn2.Open();


string writepass = "UPDATE tblUsers SET password='" + txtnewpass + "'
WHERE username='" + txtuname + "'";
OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);

Conn2.Close();
}

else
Response.Write("Incorrect credentials supplied");

Any help would be much appreciated..Thank you!
and as far as they are certain, they do not refer to reality." - Einstein
 
Hi

I just tried your suggestion and it didn't work...does my query look right? I have my if nested inside a try...when I add Cmd.ExecuteNonQuery(); , it just exits to the catch...
--
Edmond Goon

"As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Einstein


chanmmn said:
You did not execute the sql statement. Do this:

OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);
Cmd.ExecuteNonQuery;

chanmm


Edmond Goon said:
Hey guys,

I'm working on a project that has forms authentication implemented with
Access 2003. I'm trying to write a page that will allow users to change
their password. So far, without success. Here's a look at part of what I
have..
if(txtuname == (string)Session["ucode"] && txtoldpass ==
(string)Session["pword"] && txtoldpassconf == (string)Session["pword"])
{
OleDbConnection Conn2 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\PATH\\users.mdb");
Conn2.Open();


string writepass = "UPDATE tblUsers SET password='" + txtnewpass + "'
WHERE username='" + txtuname + "'";
OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);

Conn2.Close();
}

else
Response.Write("Incorrect credentials supplied");

Any help would be much appreciated..Thank you!
and as far as they are certain, they do not refer to reality." - Einstein
 
If you told a car mechanic that your car "didn't work" what would he say is
wrong with it? Nothing, of course. Instead, he would ask you how the car
behaves when you try to use it. How does your code behave when you run it?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Edmond Goon said:
Hi

I just tried your suggestion and it didn't work...does my query look
right? I have my if nested inside a try...when I add Cmd.ExecuteNonQuery();
, it just exits to the catch...and as far as they are certain, they do not refer to reality." - Einstein
chanmmn said:
You did not execute the sql statement. Do this:

OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);
Cmd.ExecuteNonQuery;

chanmm


Edmond Goon said:
Hey guys,

I'm working on a project that has forms authentication implemented
with
Access 2003. I'm trying to write a page that will allow users to change
their password. So far, without success. Here's a look at part of what I
have..
if(txtuname == (string)Session["ucode"] && txtoldpass ==
(string)Session["pword"] && txtoldpassconf == (string)Session["pword"])
{
OleDbConnection Conn2 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\PATH\\users.mdb");
Conn2.Open();


string writepass = "UPDATE tblUsers SET password='" + txtnewpass + "'
WHERE username='" + txtuname + "'";
OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);

Conn2.Close();
}

else
Response.Write("Incorrect credentials supplied");

Any help would be much appreciated..Thank you!
certain;
and as far as they are certain, they do not refer to reality." - Einstein
 
Trace the sQL statement. For now I would say that the WHERE clause doesn't
match producing no change...

Patrice

--

Edmond Goon said:
Hi

I just tried your suggestion and it didn't work...does my query look
right? I have my if nested inside a try...when I add Cmd.ExecuteNonQuery();
, it just exits to the catch...and as far as they are certain, they do not refer to reality." - Einstein
chanmmn said:
You did not execute the sql statement. Do this:

OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);
Cmd.ExecuteNonQuery;

chanmm


Edmond Goon said:
Hey guys,

I'm working on a project that has forms authentication implemented
with
Access 2003. I'm trying to write a page that will allow users to change
their password. So far, without success. Here's a look at part of what I
have..
if(txtuname == (string)Session["ucode"] && txtoldpass ==
(string)Session["pword"] && txtoldpassconf == (string)Session["pword"])
{
OleDbConnection Conn2 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\PATH\\users.mdb");
Conn2.Open();


string writepass = "UPDATE tblUsers SET password='" + txtnewpass + "'
WHERE username='" + txtuname + "'";
OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);

Conn2.Close();
}

else
Response.Write("Incorrect credentials supplied");

Any help would be much appreciated..Thank you!
certain;
and as far as they are certain, they do not refer to reality." - Einstein
 
Well, I've figured it out.

It turns out password is a reserved word in Access, and it should be between square brackets.
 
Just curious. What was the error ?

--

Edmond Goon said:
Well, I've figured it out.

It turns out password is a reserved word in Access, and it should be between square brackets.
and as far as they are certain, they do not refer to reality." - EinsteinAccess 2003. I'm trying to write a page that will allow users to change
their password. So far, without success. Here's a look at part of what I
have..
if(txtuname == (string)Session["ucode"] && txtoldpass == (string)Session["pword"] && txtoldpassconf == (string)Session["pword"])
{
OleDbConnection Conn2 = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\PATH\\users.mdb");
Conn2.Open();


string writepass = "UPDATE tblUsers SET password='" + txtnewpass + "' WHERE username='" + txtuname + "'";
OleDbCommand Cmd = new OleDbCommand(writepass, Conn2);

Conn2.Close();
}

else
Response.Write("Incorrect credentials supplied");

Any help would be much appreciated..Thank you!
certain; and as far as they are certain, they do not refer to reality." -
Einstein
 
Back
Top