How to Create a new column in excel with Vb.net and ado.net

  • Thread starter Venkateswara Kumar Kasaram via .NET 247
  • Start date
V

Venkateswara Kumar Kasaram via .NET 247

Hi,
I am working with excel as a database.first i am getting thedatafrom excel and creating dataset and later i am working withdataset,where i am creating new column in to thedataset.Finnalyi want to update the excel sheet with the datasetvalues.But i am not able to create a new columns which arecreated in dataset in to excel.

Simply:

i need to create a new column byusing VB.net and ADO.net

Kindly please help me on this
Thanks in advance
 
J

julia

Dear Venkateswara,

The ADO.NET components provide two mode of database manipulation. One is
use Command object to execute sql statement. Another is use DataSet to
mantain a local memory database and can be update to server as a whole
DataBase entity such as a DataTable. However, such update mode is "records
based". In other words, we can add or remove records from a certain
DataTable through this way( add some new rows in the certain DataTable).
But we are not able to modify the Database or a certain Table's
structure(such as add or delete a column of a DataTable and update it use
DataAdaptor.Update method). So as for your situation, if you add some
DataColumns in a certain DataTable in the local DataSet and update it to
server, it won't be able to modify the actual table's structure in the DBMS.

However, if you do want to use ADO.NET component to modify the data
table's structure on the db server. You may need to use the Command object
to execute sql statement . The following example is for SQL Server:
----------------------------------------
sqlConnection1.Open();

// add a column into a table
cmdText = "ALTER TABLE mytable ADD description char(200) ";
SqlCommand addColumnCmd = new SqlCommand ( cmdText, sqlConnection1 );
addColumnCmd.ExecuteNonQuery();

//delete a column from a table
cmdText = "ALTER TABLE mytable DROP COLUMN description"
SqlCommand dropColumnCmd = new SqlCommand ( cmdText, sqlConnection1 );
dropColumnCmd.ExecuteNonQuery();

sqlConnection1.Close();
------------------------------------------------------

Thus, we can actually modify the table's structure in the database server.

HTH

Mona

message Hi,
I am working with excel as a database.first i am getting the datafrom
excel and creating dataset and later i am working with dataset,where i am
creating new column in to the dataset.Finnalyi want to update the excel
sheet with the dataset values.But i am not able to create a new columns
which are created in dataset in to excel.

Simply:

i need to create a new column byusing VB.net and ADO.net

Kindly please help me on this
Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top