see
http://www.able-consulting.com/dotnet/adonet/Data_Providers.htm#OLEDBManagedProvider
Dim oOleDbConnection As OleDb.OleDbConnection
Dim sConnString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\myPath\myJet.mdb;"
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()make sure you give ASPNET account read/write permissions on the database file and the directory it is in
http://www.able-consulting.com/dotnet/adonet/Data_Providers.htm#OLEDBManagedProvider
Dim oOleDbConnection As OleDb.OleDbConnection
Dim sConnString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\myPath\myJet.mdb;"
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()make sure you give ASPNET account read/write permissions on the database file and the directory it is in
解决方案 »
- 一个简单的页面跳转问题,卡了1个星期没解决掉。
- xmlhttp的问题...
- datagrid中的checkbox 的checkedchanged 事件已触发,怎样获取CheckBox所在行的DataKeyField值
- 取前十个最大数
- IE6和IE7下面的搜索功能问题
- vs2003中缓存用户控件多个版本好像有点问题
- No size set for variable length data type 不明白了
- 一个关于注册的问题?
- JavaScript或者Jqurey鼠标事件
- asp.net中使用存储过程???
- “无法从resx文件中读取资料信息”的错误!如果解决?
- 如何在C#写的asp.net中的类里输出一些写html该怎么做?!
// compile with: /r:system.dll /r:system.data.dll /r:system.xml.dll
// To build this sample from the command line, use the command:
// csc /r:system.dll /r:system.data.dll /r:system.xml.dll oledbsample.csusing System;
using System.Data;
using System.Data.OleDb;
using System.Xml.Serialization;public class MainClass {
public static void Main ()
{
// Set Access connection and select strings.
// The path to BugTypes.MDB must be changed if you build the sample
// from the command line:
#if USINGPROJECTSYSTEM
string strAccessConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\BugTypes.MDB";
#else
string strAccessConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BugTypes.MDB";
#endif
string strAccessSelect = "SELECT * FROM Categories"; // Create the dataset and add the Categories table to it:
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add("Categories");
// Create Access objects:
OleDbConnection myAccessConn = new OleDbConnection(strAccessConn);
OleDbCommand myAccessCommand = new OleDbCommand(strAccessSelect,myAccessConn);
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myAccessCommand); myAccessConn.Open(); try
{
myDataAdapter.Fill(myDataSet,"Categories");
}
finally
{
myAccessConn.Close();
} try
{
// A dataset can contain multiple tables, so let's get them all
// into an array:
DataTableCollection dta = myDataSet.Tables;
foreach (DataTable dt in dta)
{
Console.WriteLine("Found data table {0}", dt.TableName);
}
// The next two lines show two different ways you can get the
// count of tables in a dataset:
Console.WriteLine("{0} tables in data set", myDataSet.Tables.Count);
Console.WriteLine("{0} tables in data set", dta.Count);
// The next several lines show how to get information on a
// specific table by name from the dataset:
Console.WriteLine("{0} rows in Categories table", myDataSet.Tables["Categories"].Rows.Count);
// The column info is automatically fetched from the database, so
// we can read it here:
Console.WriteLine("{0} columns in Categories table", myDataSet.Tables["Categories"].Columns.Count);
DataColumnCollection drc = myDataSet.Tables["Categories"].Columns;
int i = 0;
foreach (DataColumn dc in drc)
{
// Print the column subscript, then the column's name and its
// data type:
Console.WriteLine("Column name[{0}] is {1}, of type {2}",i++ , dc.ColumnName, dc.DataType);
}
DataRowCollection dra = myDataSet.Tables["Categories"].Rows;
foreach (DataRow dr in dra)
{
// Print the CategoryID as a subscript, then the CategoryName:
Console.WriteLine("CategoryName[{0}] is {1}", dr[0], dr[1]);
}
}
catch (Exception e)
{
Console.WriteLine("Oooops. Caught an exception:\n{0}", e.Message);
}
}
}