Search : in
By :

Error in connection of asp.net & ms access

Sumon, on Sep 17, 2009 7:46:53 pm BST 
 Report this message to moderators

Hello,
i am using Visual Studio 2008 and i am trying to connect a simple database inventory.mdb (i use microsoft office 2002) with asp.net using the following code.

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Runtime.Serialization;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class increase_stock : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        //SqlConnection con = new SqlConnection("Server=You server name or comp name;Database=Yourdatabasename;Trusted_Connectopn=True");
        SqlConnection con = new SqlConnection("Server=Microsoft.Jet.OLEDB.4.0;Database=c:\\inventory.mdb;Trusted_Connectopn=True");   //Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c:\AccessDB\MyDB.mdb;User Id=admin;Password=;")

        SqlCommand cmd = new SqlCommand("select * from all_products");
        con.Open();
        DataSet ds = new DataSet(cmd, con);
        SqlDataAdapter da = new SqlDataAdapter();
        da.Fill(ds);
        con.Close();
   }
}

But it shows me the following errors
Error	1	The best overloaded method match for 'System.Data.DataSet.DataSet(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' has some invalid arguments	J:\my_document\Visual Studio 2008\WebSites\inventory\increase_stock.aspx.cs	30	22	J:\...\inventory\
Error	2	Argument '1': cannot convert from 'System.Data.SqlClient.SqlCommand' to 'System.Runtime.Serialization.SerializationInfo'	J:\my_document\Visual Studio 2008\WebSites\inventory\increase_stock.aspx.cs	30	34	J:\...\inventory\
Error	3	Argument '2': cannot convert from 'System.Data.SqlClient.SqlConnection' to 'System.Runtime.Serialization.StreamingContext'	J:\my_document\Visual Studio 2008\WebSites\inventory\increase_stock.aspx.cs	30	39	J:\...\inventory\


i am super nobie in asp.net or visual studio but not in web development. so please suggest me is it the correct way to connect database?
lastly, i expect a tiny project like simple registration system using asp.net(version: visual studio 2008) and ms access. i shall highly appreciate if i have a good tutorial.
Configuration: Windows XP
Firefox 3.0.14

Best answers for « error in connection of asp.net & ms access » in :
Error connection with iphone ShowError connection with iphone After installation of installation of updates on your iPhone in view to access new applications from the apple storem, Iphone refuse to login and and display error which unable to login. To troubleshoot...
Error connection- 0x80072ee6 ShowError connection- 0x80072ee6 Below is a tips of a how to solve this problems. First of all, delete the cookies and clear the history and internet cache of Internet explorer. Then click on Start > Run and type the...
Error Connection (80048820) ShowError Connection (80048820) Solutions Before any configuration on your system, it is recommended that you check the status of MSN Messenger servers to determine if the problem does not come from there:...
Download .NET Framework ShowMicrosoft .NET Framework 3.5 contains new features which have been built upon .NET Framework 2.0 and 3.0, and includes .NET Framework 2.0 service pack 1 and .NET Framework 3.0 service pack 1. Microsoft .NET Framework 3.5 includes: - ASP .NET AJAX...
ODBC ShowWhat is ODBC? ODBC stands for Open Database Connectivity. This is a Microsoft-defined format for communicating between Windows database clients and consumer DBMSs. The ODBC managier can be found in Windows 3.1 and 9x. In Windows 95 and 98, it is...