473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

add columns (modify) Datatable AND source MDB

I have a program that runs a query ("Select * From MyTable") on an Access
Database and saves the results in a DataTable (see function, below). The
program then adds columns to the DataTable, then updates rows in the
DataTable with data for the new columns. I can write the DataTable to XML
and see the changes I have made.

How can I get the changes I have made to my DataTable to apply to my Access
Database?

HERE IS THE CODE USED TO GET THE DATATABLE:

Private Function DoSQLQuery(ByVal sQuery As String) As DataTable

Dim oDbReader As SqlDataReader
Dim oDataAdapter As SqlDataAdapter

Dim oDbCommand As SqlCommand
If gbForeignQueryBuilder Then
goDataTable = New DataTable("Query")
Else
goDataTable.Clear()
End If

gSqlConnection = New SqlConnection(gsConnectionString)

Try
gSqlConnection.Open()
oDbCommand = New SqlCommand(sQuery, gSqlConnection)
oDataAdapter = New SqlDataAdapter(oDbCommand)
oDataAdapter.Fill(goDataTable)
Return goDataTable
Catch e As Exception
Const ERR_IN_QUERY = 1002
Err.Raise(ERR_IN_QUERY, Me.CLASS_NAME, "Error in Query: " & e.ToString())
Finally
If Not (oDbReader Is Nothing) Then
oDbReader.Close()
End If
If Not (gSqlConnection Is Nothing) Then
gSqlConnection.Close()
End If
End Try

End Function
Feb 13 '06 #1
1 1287
CMM
AFAIK you're going to have to execute DDL commands to do this. The
DataAdapter doesn't modify schemas. This isn't hard... just as you add them
to the Dataset, execute ALTER TABLE commands on the database.

--
-C. Moya
www.cmoya.com
Feb 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
13
by: scorpion53061 | last post by:
Very urgent and I am very close but need a little help to get me over the edge........ I need to write these columns to a html file with each row containing these columns (seperated by breaks)....
5
by: Gary Blakely | last post by:
I'm giving this post another try - it can't be too difficult for everyone.... In the program below, the web page has dataGrid1. the only thing that has been done to it at design time is to...
4
by: Sam | last post by:
Hi, I'm adding columns to a datatable as followed. The values are from textboxes or comboboxes. The first column is properly field but then all the subsequent columns just contain "", whereas the...
1
by: thomasp | last post by:
Will someone tell me why with the following code: 1. The user can not resize the columns 2. The DTG column is not formatted as "dd-MMM-yy HH:mm:ss" 3. The user can modify the data in all...
8
by: George | last post by:
Hi, I have been trying to see if I can do the following: 1. Create a DataGridView 2. Create 2 columns in the DataGridView (1 textbox and the other combobox) 3. Create a DataTable containing...
5
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can...
2
by: canoewhiteh2o | last post by:
I am having trouble adding data columns to a disconnected database. I first load a datatable using: private DataTable dtMacros = new DataTable(); private ArrayList macro = new ArrayList();...
1
by: Mark Baldwin | last post by:
Steven Thanks for your reply, however the typed datasets are defined in the web service and there seems to way to open the partial class code window - double clicking on the design surface does...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.