I'm converting a vb class to C#/.Net. I can't find equivalents for the following:
RecordSet
FieldAttributeEnum
DataTypeEnum
I think RecordSet can be replaced with DataSet, but I don't know about the other two. Any ideas?
Some example code:
Private Function CreateRecordsetFromDataGrid(ByVal DGV As DataGridView) As Recordset Dim rs As New Recordset 'Create columns in ADODB.Recordset Dim FieldAttr As FieldAttributeEnum FieldAttr = FieldAttributeEnum.adFldIsNullable Or FieldAttributeEnum.adFldIsNullable Or FieldAttributeEnum.adFldUpdatable For Each iColumn As DataGridViewColumn In DGV.Columns 'only add Visible columns If iColumn.Visible = True Then Dim FieldType As DataTypeEnum 'select dataType If iColumn.ValueType Is GetType(Boolean) Then FieldType = DataTypeEnum.adBoolean
Create ADO Connection and Recordset Objects in Visual C# .NET
Create a new Visual C# .NET Windows application project.
On the Project menu, click Add Reference.
Click the COM tab. Click Microsoft ActiveX Data Objects 2.X Library.
// You must first load the COM reference Microsoft ActiveX Data Objects 2.X Library private ADODB.Recordset CreateRecordsetFromDataGrid(DataGridView DGV) { ADODB.Recordset rs = new ADODB.Recordset(); try { ADODB.FieldAttributeEnum FieldAttr = ADODB.FieldAttributeEnum.adFldIsNullable | ADODB.FieldAttributeEnum.adFldUpdatable; foreach (DataGridViewColumn iColumn in DGV.Columns) { if (iColumn.Visible) { ADODB.DataTypeEnum FieldType; if (iColumn.ValueType == typeof(Boolean)) { FieldType = ADODB.DataTypeEnum.adBoolean; } } } } catch (Exception ex) { // Don't leave this blank! } return rs; }
Create ADO Connection and Recordset Objects in Visual C# .NET
Create a new Visual C# .NET Windows application project.
On the Project menu, click Add Reference.
Click the COM tab. Click Microsoft ActiveX Data Objects 2.X Library.
Open in new window