hi i need some help, i need to creat a file in access 2003 running a aplication asp.net (c#) using a sql query, if anyone knows that plz tell me:)

thanks

So there are various components regarding your question. You need to be more specific. In addition, if this a homework assignment, you need to put a little more effort in describing the assignment, what you have done so far, and exactly what you are having trouble with.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ADOX;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using ADODB;

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

            createdb("c:\\temp\\my1.mdb");
        }
        protected void createdb(string path)
        {
            try
            {
                string connString;
                string fileName = path;


                ADODB.Connection myconn = new Connection();
                connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + fileName + "; Jet OLEDB:Engine Type=5";
                ADOX.Catalog myCatalog = new Catalog();



                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ConnectionString);
                string sql = ("SELECT * FROM dbo.aspnet_rolesindir");

                SqlCommand com = new SqlCommand();
                com.CommandText = sql;
                com.Connection = conn;
                conn.Open();

                if (!(File.Exists(fileName)))
                {
                    myCatalog.Create(connString);
                    myCatalog = null;
                }

                myconn.Open(connString, "", "", 0);
                myCatalog.ActiveConnection = myconn;

            }
            catch (Exception e)
            {
                Console.Write("\n" + e.ToString() + "\n");
            }
        }
    }
}

i have this code, only create a empty database, i want create a database using a sql server query.. export a sql server table to access(mdb)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.