Re: Table data into Array
datareader would be one method.
Re: Table data into Array
DataTable will provide you a Row collection, and each row will contain the fields selected in your query. So you would access a value using:
Code:
string value = dtResults.Rows[0]["FIELDNAME"].ToString();
Code:
DataTable dtResults = new DataTable();
OleDbConnection dbConnection = new OleDbConnection("your connection string");
try
{
dbConnection.Open();
if (dbConnection.State == ConnectionState.Open)
{
OleDbCommand dbCommand = dbConnection.CreateCommand();
dbCommand.CommandType = CommandType.Text;
dbCommand.CommandText = "your query (select * from...)";
OleDbDataReader dbReader = dbCommand.ExecuteReader();
if (dbReader.HasRows)
dtResults.Load(dbReader);
dbReader.Close();
dbConnection.Close();
}
}
catch (Exception ex)
{
throw new Exception("Unable to execute query as requested.", ex);
}
Re: Table data into Array
Hello
This can also help you, try this
Dim rst As DAO.Recordset
Dim lngNum As Long
Set rst = CurrentDb.Open("TableNameHere")
For 1 to UBound(YourArray)
With rst
.AddNew
!FieldName = YourArray(lngNum)
.Update
End With
lngNum = lngNum + 1
Next
There may be error, not tested, just an overview.
Re: Table data into Array
Thanks for the effort. But, that code is for VB6. This is the C# Forum. Also, that code uses DAO. In .NET ADO is most common...