tables search

  • Thread starter Thread starter Hrvoje Voda
  • Start date Start date
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
 
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
 
Back
Top