I know I can drag/drop an sqlDataSource
object onto my webform and then get my connection string from my webconfig file and link it and done... But I don't want to do it that way. I want to do it programmatically.
as it can be done in a windows form app like so:
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionDev"].ConnectionString);
string command = "SELECT * FROM DUMMY";
SqlDataAdapter dataAdapter = new SqlDataAdapter(command, conn);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
dgvDelete.DataSource = ds.Tables[0];
How can I do this in a web form?
I think I have to use the sqlDataSource
object and set it up that way but I don't know how.
Can someone show me?