.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Code Snippets >> DataGrid >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

show the match data in a datagridview

Posted By:Nikhil Kumar       Posted Date: February 20, 2010    Points: 10    Category: DataGrid    URL: http://www.dotnetspark.com  

This code sample will show you how to show the match data in a datagridview by a textbox calling method.

Type a id in text box and click on the search
button it will show the mach data by the typed id
private void button1_Click(object sender, EventArgs e)
    string se;
    se = "select * from ja where id = @id";
    SqlConnection con = new SqlConnection();
    con.ConnectionString = "data source= Jbb-690ab60e108; Initial catalog = datamaster; Integrated security = true";
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = con;
    cmd.CommandText = se;
    SqlParameter pp = cmd.Parameters.Add("@id", SqlDbType.VarChar, 10);
    pp.Value = textBox1.Text;
    SqlDataAdapter adapter = new
    DataTable dt = new DataTable();
        dataGridView1.DataSource = dt;



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend