Passing table name as Parameter in SQL
Posted By: jokertin92 Posted Date: April 24, 2010
Points:2 Category :C#
I would like to retrieve data from a table, where the table has to be taken dynamically. How can I get this, can any one guide me?
I tried the following
private void filldatagrid()
using (conn = new SqlConnection(Helper.ConnectionString))
logfrm = new Login();
comm = new SqlCommand("SELECT * FROM"+@Location",conn);
da = new SqlDataAdapter(comm);
ds = new DataSet();
dataGridView1.DataSource = ds.Tables;
But shows "Incorrect Syntax near from+@location"
You must Sign In To post reply