Please can somebody tell me how to show data in datagridview through dataadapter and dataset from data base...
Please reply me quickly i need it. it's urgent
Regards
Zeb
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Zeb RehmanPosted Dec 13, 2011, 2:48 AM
Satyapriya NayakPosted Dec 12, 2011, 11:12 PM
If this post helps you mark it as answer
Thanks
Satyapriya NayakPosted Dec 12, 2011, 9:52 AM
str = "select custid,custname from customer";
Here custid and custname will be displayed in the datagridview.If you use * all columns will be displayed in the datagridview.
Thanks
Zeb RehmanPosted Dec 12, 2011, 9:29 AM
Satyapriya NayakPosted Dec 12, 2011, 9:22 AM
Try this...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Datagridview_bind
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
OleDbDataAdapter oda;
DataSet ds;
string str;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from customer";
com = new OleDbCommand(str, con);
oda = new OleDbDataAdapter(com);
ds = new DataSet();
oda.Fill(ds, "customer");
dataGridView1.DataMember = "customer";
dataGridView1.DataSource = ds;
con.Close();
}
}
}
Thanks