tables search

H

Hrvoje Voda

I'm using this code to get search result from 8 tables...

SqlConnection conn = null;

conn = new

SqlConnection(sConn);

conn.Open();

SqlCommand cmd = new SqlCommand();

cmd.CommandText = "dbo.[SearchBaseAll]";

cmd.CommandType = CommandType.StoredProcedure;

cmd.Connection = conn;

cmd.Parameters.Add(new SqlParameter("@Tekst",""));

cmd.ExecuteNonQuery();

gd.Grid.DataMember = "";

SqlDataAdapter adap = new SqlDataAdapter();

adap.SelectCommand = cmd;

DataSet ds = new DataSet();

adap.Fill(ds,WHAT COMES HERE ? );

gd.Grid.DataSource = ds.Tables[WHAT COMES HERE ?];



Hrcko
 
S

Slawomir

Hrvoje Voda pisze:
adap.Fill(ds,*WHAT COMES HERE ?* );
Name of one of DataTables in your dataset.
gd.Grid.DataSource = ds.Tables[*WHAT COMES HERE ?*];
Name of index of DataTable in DataSet from witch you want receive data.

But for me, you don't need to use DataSet. If all data you have as one
result DataTable is enough.

DataTable dt = new DataTable();
adap.Fill(dt);
gd.Grid.DataSource = dt;

Don't forget to close connection to database after receiving data:
conn.Close();

best,
Slawomir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top