Private void Button1_Click(object sender, System.EventArgs e) { con=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:signin.mdb;Persist Security Info=False"); string s; s="select * from login where username='" + TextBox1.Text + "'and password='" + TextBox2.Text + "'"; ad.SelectCommand.CommandText=s; ds=new DataSet(); ad.Fill(ds); if(ds.Tables[0].Rows.Count>0) { Label3.Text ="valid user"; } else Label3.Text="Invalid user"; }Whenever i am using adapter wizard there is no error. but through coding getting error as Object reference not set to an instance of an object. How to rectify it?

Showing Answers 1 - 5 of 5 Answers

Chakravarthi

  • Oct 5th, 2006
 

May be your no intializing the adapter class object . check once again the declaration & intiatlization block

ad = new OledbAdapter

ad.connection=con

  Was this answer useful?  Yes

Guru

  • Nov 5th, 2006
 

try

{

OledbConnection con=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:signin.mdb;Persist Security Info=False");
string s;
s="select * from login where username='" + TextBox1.Text + "'and password='" + TextBox2.Text + "'";
OledbDataaAdapter ad=new  OledbDataAdaptead();

ad.SelectCommand.CommandText=s;
DataSet ds=new DataSet();
ad.Fill(ds);
if(ds.Tables[0].Rows.Count>0)
{
Label3.Text ="valid user";
}
else
Label3.Text="Invalid user";

}

catch(Exception ex)

{

Response.Write(ex.Message());

}

  Was this answer useful?  Yes

suryaprasad

  • Nov 10th, 2006
 

can anyone explaine me what this pesist security info =false is thanks in advance

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions