PLEASE Enter:)

Aug 17 2007 5:35 PM

hello members, hows everything goin ?

i am finishing my website and i got some problems and i need your help guys please.

first of all i've made these two methods the first one seems to work gr8 but in the other one that updates table values, i get '0' value in my field when i run the methods on my application and it doesn't update the required field at all. this is the code:

//this one checks if both username and password match together.

public bool NameAndPass(string user, string pass)

{

bool NameAndPassflag = false;

string queryStr = "SELECT * FROM admin where username='" + user + "' AND password='" + pass + "' ";

OleDbConnection connectObj = new OleDbConnection(this.connectionStr);

OleDbCommand commandObj = new OleDbCommand(queryStr, connectObj);

OleDbDataReader readerObj;

connectObj.Open();

readerObj = commandObj.ExecuteReader();

if (readerObj.Read())

{

NameAndPassflag = true;

readerObj.Close();

}

connectObj.Close();

return NameAndPassflag;

}

//this method updates the password

public void ModifyPass(string user, string pass)

{

string queryStr = "UPDATE admin SET username ='" + user + "' AND password='" + pass + "' WHERE username='"+user+"' ";

OleDbConnection connectObj = new OleDbConnection(this.connectionStr);

OleDbCommand cmd = new OleDbCommand(queryStr, connectObj);

connectObj.Open();

cmd.ExecuteNonQuery();

connectObj.Close();

}

_____________

//this is the way i used it on my changepassword.aspx page

 

protected void ChangePasswordBtn_Click(object sender, EventArgs e)

{

string connectionStr = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("DB.mdb");

Admin change = new Admin(connectionStr);

if (change.NameAndPass(this.txtBoxUserName1.Text, this.txtBoxOldPass.Text))

{

change.ModifyPass(this.txtBoxUserName1.Text, this.txtBoxNewpass.Text);

this.lblChangePassWord.Text = "updated";

}

}

||__________________________________________________||

Another problem that is driving me crazy.. i made a code that reads the path of an uploaded pictures from my pc and saves it in the image.url .. but the problem is that its not showing my the pictures, this is the code anyway:

public void FillthePhotos()

{

string connectionStr = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("DB.mdb");

string sqlStr = "Select * FROM pictures";

OleDbDataAdapter daObj = new OleDbDataAdapter(sqlStr, connectionStr);

DataSet dsObj = new DataSet();

daObj.Fill(dsObj);

DataTable dataTable = dsObj.Tables[0];

foreach (DataRow row in dsObj.Tables[0].Rows)

{

this.imagesp1.ImageUrl = dsObj.Tables[0].Rows[0]["picture_path"].ToString();

this.imagesp2.ImageUrl = dsObj.Tables[0].Rows[1]["picture_path"].ToString();

this.imagesp3.ImageUrl = dsObj.Tables[0].Rows[2]["picture_path"].ToString();

this.imagesp4.ImageUrl = dsObj.Tables[0].Rows[3]["picture_path"].ToString();

}

}

 

please guys any help would be gr8, and sorry for my bad english


Answers (1)