Here is what you should do:
- The user used to connect to the DB must have privileges to create objects (tables)
- Connect to the DB by creating an SqlConnection object and providing a Connection string
-Open the connection.
- create SqlDataAdapter, SqlCommand objects to execute the CREATE TABLE ... by calling ExecuteNoQuery() on the SqlCommand object.
- if done successfull then call Fill() on the DataAdapter to create a DataTable object by sending the SQL command text : "Select * from thattable";
-Update the DataTable object e.g. add rows, modify, delete
- create a SqlCommandBuilder object using the above SqlDataAdapter object and call the Update() method to put back (commit) the DataTable in the data source.
-If you still to continue to update the DataTable object after this step then call AcceptChanges() on the DataTable object.
- Cleanup (Dispose()) no nedeed objects
Use try-catch block to capture any error on each above steps and take actions accordingly.
-obislavu-
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.