Solved

how retrieve data acccess db with c#

Posted on 2012-03-23
2
242 Views
Last Modified: 2012-03-29
hi..

i'm making a web application in c# read access db this is my code:

        protected void Consultar_Click1(object sender, EventArgs e)
        {
            string sql = @"SELECT Id_Venta
                                  ,Id_Producto
                                  ,Cantidad
                                  ,Fecha_Venta
                                  ,Id_Cajero
                              FROM VENTAS
                              WHERE Id_Venta = @Id";

            string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\TOÑO\\daniel\\Database21.mdb";
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connectionString);
            System.Data.OleDb.OleDbDataAdapter myDataAdapter = new System.Data.OleDb.OleDbDataAdapter("SELECT * FROM VENTAS where ID_Venta = '" + "1" + "'", conn);
            System.Data.DataSet myDataSet = new System.Data.DataSet("VENTAS");
            myDataAdapter.Fill(myDataSet, "VENTAS");
           
            conn.Close();
           
            return ;





            }


someone can help me...i need to put data retrieved at textboxes, but i don't know wich stape missing

thanks a lot
0
Comment
Question by:tenriquez199
2 Comments
 
LVL 9

Accepted Solution

by:
gery128 earned 500 total points
ID: 37766130
are you getting data in myDataSet?
If yes then you can easily access it through Table and row/column properties of the myDataSet.
the syntaxt is like this:
txtName.Text = myDataSet.Tables[0].Rows[0][0].ToString();

http://bytes.com/topic/c-sharp/answers/235606-c-how-get-value-dataset

http://www.velocityreviews.com/forums/t109472-accessing-a-value-from-a-dataset.html
0
 
LVL 1

Author Closing Comment

by:tenriquez199
ID: 37785065
thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now