问题描述
在sql中使用连接字符串我保存了数据。所有记录都在数据库中。
i希望MS Access数据库在MS Access中存储记录数据库。
Sql conncetion字符串如下;
private string himtConnectionString =Data Source = india; connect timeout = 120; Initial Catalog = HIMTTESTing; User ID = sgv; Password = s123;
如何为MS Access数据库写连接字符串。
private string Accessconncetionstring =Provider = microsoft.jet.OLEDB.4.0; Data Source = C:\ HIMTTESTing.mdb;
上面的MS Access Accessconncetionstring是正确的。请帮助我。
我该怎么办。
i不知道。请帮助我。我想要答案。
using connection string in sql i saved the data.All records are there in the data base.
i want to MS Access Database to store the record in MS Access DataBase.
Sql conncetion string as follows;
private string himtConnectionString = "Data Source=india;connect timeout = 120; Initial Catalog=HIMTTESTing;User ID=sgv;Password =s123 ";
how to write connection string for MS Access Data Base.
private string Accessconncetionstring = "Provider = microsoft.jet.OLEDB.4.0;Data Source=C:\HIMTTESTing.mdb";
the above Accessconncetionstring for MS Access is correct.please help me.
how can i do.
i don''t know.please help me.i want the answer.
推荐答案
<connectionStrings>
<!-- connection string declared for connecting the web application with MS Access 2007 -->
<!-- connection string for MS Access 2007 accdb file -->
<add name="AccessConnectionString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|db1.accdb;Persist Security Info=False;Jet OLEDB:Database Password=;" providerName="System.Data.OleDb" />
</connectionStrings>
// import the following namespaces
using System.Configuration;
using System.Data;
using System.Data.OleDb;
// create an OldDbConnection object and initialize it by passing connection string.
// ConfigurationManager class provides the ConnectionStrings collection type property
// to access the connection string stored in the web.config file.
OleDbConnection myDataConnection = new OleDbConnection(ConfigurationManager.ConnectionStrings["AccessConnectionString"].ConnectionString);
// open the data connection.
myDataConnection.Open();
// display the connection's current state open/closed.
Response.Write(string.Format("<i><b>Connection state:</b> {0}</i><br />", myDataConnection.State));
// close the data connection.
myDataConnection.Close();
// again display the connection's current state open/closed.
Response.Write(string.Format("<i><b>Connection state:</b> {0}</i>", myDataConnection.State));
// dispose the connection object to release the resources.
myDataConnection.Dispose();
这篇关于如何在MSAccess中使用conncetion字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!