Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > Need help working with Ado

Reply
Thread Tools

Need help working with Ado

 
 
personaje personaje is offline
Junior Member
Join Date: Dec 2008
Posts: 2
 
      12-26-2008
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
 
Reply With Quote
 
 
 
 
marshal marshal is offline
Junior Member
Join Date: Dec 2008
Posts: 4
 
      12-29-2008
for example
Code:
// Create DataTable A
private DataTable CreateDataTableA()
{
DataTable aTable = new DataTable("A");
DataColumn dtCol;
DataRow dtRow;
// Create ID column and add to the DataTable.
dtCol = new DataColumn();
dtCol.DataType= System.Type.GetType("System.Int32");
dtCol.ColumnName = "ID";
dtCol.AutoIncrement = true;
dtCol.Caption = "ID";
dtCol.ReadOnly = true;
dtCol.Unique = true;
// Add the column to the DataColumnCollection.
aTable.Columns.Add(dtCol);
// Create Name column and add to the table
dtCol = new DataColumn();
dtCol.DataType= System.Type.GetType("System.String");
dtCol.ColumnName = "FName";
dtCol.AutoIncrement = false;
dtCol.Caption = "First Name";
dtCol.ReadOnly = false;
dtCol.Unique = false;
aTable.Columns.Add(dtCol);
// Create Last Name column and add to the table.
dtCol = new DataColumn();
dtCol.DataType= System.Type.GetType("System.String");
dtCol.ColumnName = "LName";
dtCol.AutoIncrement = false;
dtCol.Caption = "Last Name";
dtCol.ReadOnly = false;
dtCol.Unique = false;
aTable.Columns.Add(dtCol);
// Create three rows to the table
dtRow = aTable.NewRow();
dtRow["ID"] = 1001;
dtRow["FName"] = "Mahesh";
dtRow["LName"] = "Chand" ;
aTable.Rows.Add(dtRow);
dtRow = aTable.NewRow();
dtRow["ID"] = 1002;
dtRow["FName"] = "Melanie";
dtRow["LName"] = "Talmadge" ;
aTable.Rows.Add(dtRow);
dtRow = aTable.NewRow();
dtRow["ID"] = 1003;
dtRow["FName"] = "Vinay";
dtRow["LName"] = "Bansal" ;
aTable.Rows.Add(dtRow);
return aTable;
}
// Create DataTable B
private DataTable CreateDataTableB()
{
DataTable bTable = new DataTable("B");
DataColumn dtCol;
DataRow dtRow;
// Create ID column and add to the DataTable.
dtCol = new DataColumn();
dtCol.DataType= System.Type.GetType("System.Int32");
dtCol.ColumnName = "CustomerID";
dtCol.AutoIncrement = true;
dtCol.Caption = "CustomerID";
dtCol.ReadOnly = true;
dtCol.Unique = true;
// Add the column to the DataColumnCollection.
bTable.Columns.Add(dtCol);
// Create Name column and add to the table
dtCol = new DataColumn();
dtCol.DataType= System.Type.GetType("System.String");
dtCol.ColumnName = "Name";
dtCol.AutoIncrement = false;
dtCol.Caption = "Name";
dtCol.ReadOnly = false;
dtCol.Unique = false;
bTable.Columns.Add(dtCol);
// Create Last Name column and add to the table.
dtCol = new DataColumn();
dtCol.DataType= System.Type.GetType("System.String");
dtCol.ColumnName = "Address";
dtCol.AutoIncrement = false;
dtCol.Caption = "Address";
dtCol.ReadOnly = false;
dtCol.Unique = false;
bTable.Columns.Add(dtCol);
// Create three rows to the table
dtRow = bTable.NewRow();
dtRow["CustomerID"] = 11;
dtRow["Name"] = "Mr. Peter Ferrera";
dtRow["Address"] = "9th Street, Bank Road, NOIDA" ;
bTable.Rows.Add(dtRow);
dtRow = bTable.NewRow();
dtRow["CustomerID"] = 21;
dtRow["Name"] = "Ross Tomo";
dtRow["Address"] = "North Street, Parkway Road, SunCity" ;
bTable.Rows.Add(dtRow);
dtRow = bTable.NewRow();
dtRow["CustomerID"] = 31;
dtRow["Name"] = "Dr. Jog Rocky";
dtRow["Address"] = "Turnpike Avenue, Philly" ;
bTable.Rows.Add(dtRow);
return bTable;
}
 
Reply With Quote
 
 
 
 
personaje personaje is offline
Junior Member
Join Date: Dec 2008
Posts: 2
 
      12-29-2008
But I have created the table, so I don't need to created again. What I need is to move the data from the grid to the table I have created, but the table is using ado in reference to adox
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help accessing XML Elements with ASP/ADO gmlear XML 1 03-19-2005 04:28 AM
Translating Oracle Package Call from ADO to ADO.Net dmiratsky@yahoo.com ASP .Net 0 02-14-2005 10:39 PM
Transfer ADO Code to ADO.NET ronaldlee ASP .Net 1 12-17-2004 04:08 PM
Accessing an ADO Recordset or Record from ADO.NET nita ASP .Net 1 11-20-2004 07:06 AM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments