Need help working with Ado.net

vb.net , cpp , csharp San Juan, Puerto Rico
  • 8 years ago
    I am new to VB, I made a table using ado, but I need to pass the data from a datagrid to the table. The code for the table is like this: Dim TableName As String = "" 'Giving name to the table TableName = "Pareo" Dim dsStr As String Dim dsCn As String Dim cnADO As ADODB.Connection Dim mdb As ADOX.Catalog Dim dt As ADOX.Table Try mdb = New ADOX.Catalog() cnADO = New ADODB.Connection() dsStr = My.Settings.DataSource dsCn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dsStr + ";" cnADO.ConnectionString = dsCn cnADO.Open() mdb.ActiveConnection = cnADO 'Creating the table dt = New ADOX.Table() dt.Name = nombreTabla dt.Columns.Append("Num", ADOX.DataTypeEnum.adWChar, 5) dt.Columns.Append("NI", ADOX.DataTypeEnum.adWChar, 10) dt.Columns.Append("Name", ADOX.DataTypeEnum.adWChar, 20) dt.Columns.Append("Rnd" & i, ADOX.DataTypeEnum.adWChar, 5) dt.Columns.Append("EloBirdInicial", ADOX.DataTypeEnum.adWChar, 10) dt.Columns.Append("EloBirdFinal", ADOX.DataTypeEnum.adWChar, 10) dt.Keys.Append("PK_NewTable", ADOX.KeyTypeEnum.adKeyPrimary, _ "NI") mdb.Tables.Append(dt) Catch ex As Exception MessageBox.Show(ex.Message, "The table was not created") End End Try MessageBox.Show("The table was created", "Now", MessageBoxButtons.OK) End I need to pass data form a datagrid to this table, I hope someone can help me

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves” - Alan Kay