Click here to Skip to main content
15,891,726 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
string Constr = ConfigurationManager.ConnectionStrings["YET_DatabaseConnectionString"].ConnectionString.ToString();
            SqlConnection conn = new SqlConnection(Constr);
            conn.Open();
            string DConsignor = DDConsigner.Text;
            sql = "select * from Bilty where Consigner='"+ DConsignor  +"'";
            SqlCommand cmd = new SqlCommand(sql, conn);
          //  SqlDataReader rd = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
           // dt= this.getgridforConsignor(DConsignor);
            getgridforConsignor(DConsignor);
            //GridView1.DataSource = dt;
            //GridView1.DataBind();
            conn.Close();
Posted
Updated 1-Jul-11 1:39am
v2
Comments
Prerak Patel 1-Jul-11 7:39am    
Please elaborate.

Use a DataAdapter to fill the dataset

http://msdn.microsoft.com/en-us/library/bh8kx08z%28v=VS.100%29.aspx[^]

e.g.

// Assumes that connection is a valid SqlConnection object.
string queryString = 
  "SELECT CustomerID, CompanyName FROM dbo.Customers";
SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection);

DataSet customers = new DataSet();
adapter.Fill(customers, "Customers");


The DataSet will contain tables, which you can obtain a reference to and then DataBind to your grid
 
Share this answer
 
string strConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection strConn = new  SqlConnection(strConnectionString );
strConn.Open();        
string sqlStatement = "SELECT * from tblCountry";
        SqlCommand cmd = new SqlCommand(sqlStatement, strConn);
        cmd.CommandType = CommandType.Text;
        DataSet ds = new DataSet();
        SqlDataAdapter sqlDA = new SqlDataAdapter(cmd);
        
        sqlDA.Fill(ds);
        cmd.ExecuteNonQuery();
        
        if (ds.Tables[0].Rows.Count > 0)
        {
            grdEditCountry.DataSource = ds.Tables[0];
            grdEditCountry.DataBind();
        }
strConn.Close();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900