Having a problem using MS Access in Asp .net DataReader [Resolved]

Posted by MindLess under Regular Expressions on 11/17/2010 | Points: 10 | Views : 1228 | Status : [Member] | Replies : 2
In my project, I am using Asp .net 3.5 my database is MS Acccess I am having a problem with datbase connetion. I want to know the actual parameter to access the data from data base with Oledb Data adapter can any member help me about this problem.

thanks in advance




Responses

Posted by: SheoNarayan on: 11/17/2010 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
Hello MindLess,

You will need to learn ADO.NET for that. Below are the sample code. I would suggest instead of just copying and pasting this code, try to understand what is written and why it is written that will help you to understand and write code on you own in future.

try

{
DataTable dTable = new DataTable();
using (OdbcConnection conn = new OdbcConnection(connStr))
{
conn.Open();
using (OdbcCommand dCmd = new OdbcCommand("Select * from errorlog limit 0, 10", conn))
{
using (OdbcDataAdapter dAd = new OdbcDataAdapter(dCmd))
{
dAd.Fill(dTable);
}
}
}
GridView1.DataSource = dTable;
GridView1.DataBind();
}
catch (Exception ee)
{
lblError.Text = ee.ToString();
}


Thanks and good luck.

Regards,
Sheo Narayan
http://www.dotnetfunda.com

MindLess, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: MindLess on: 11/18/2010 [Member] Starter | Points: 25

Up
0
Down
Thank you Narayan
Actully I am new in Asp .Net and have a urgent project. but now I am using data adapter and it's working now.
thanks

MindLess, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response