senthil

senthil

  • NA
  • 27
  • 0

Problem in creating table at runtime in c#.. Plz Help Dear ones... URGENT

Nov 15 2009 11:52 AM


 I have a three textbox in my form and a button
one to table name ( Example  .Emp details)
two to get field name(Example ID)
three to get field value(Example 10)

i need a code to pass values in run time and all should be stored in SQL

i dont know  code but plz Help me.. im getting Error..

protected void Button1_Click(object sender, EventArgs e)
    {
SqlConnection con=new SqlConnection("Data Source=localhost;Initial Catalog=Northwind;User Id=sa;Password=sa");

SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM "+ TextBox1.Text +"",con);

SqlCommand CMD = new SqlCommand("Create table "+ TextBox1.Text +"("+ TextBox2.Text +" )values( '"+ TextBox3.Text +"')",con);                                                       

DataSet ds = new DataSet();

da.Fill(ds,"+ TextBox1.Text +");

DataGrid1.DataSource=ds;

DataGrid1.DataMember="+ TextBox1.Text +";

DataGrid1.DataBind();

con.Open();

CMD.ExecuteNonQuery();

con.Close();

 }



Please dear friend Help me soon

If any doubt mail me at [email protected]

Thank u

senthil kumar.

Answers (9)