本文介绍了如何通过web.config连接到Access数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



谁能告诉我如何使用web.config文件连接数据库.我正在使用Access.我想检查数据库中的用户名和密码.我无法使用VB.NET通过web.config连接到数据库.


Hi,

Can anybody tell me how to connect to a database using the web.config file. I''m using Access. I want to check for username and password in the database. I''m unable to connect to the database through web.config using VB.NET.


//in vb.net

 Dim connStr As String = ConfigurationManager.ConnectionStrings("MainConnStr").ConnectionString

 sqlcom = New OleDbCommand("select * FROM registered_customers WHERE login_name= '" & userName & "'  AND pword='" & password & "'", connstr)





//in web.config
<removed name="LocalSqlServer&quot" />
   <removed name="LocalSqlServer" connectionsting="Data Source=E:\Anil\kank.mdb;User Instance=true" providername="Microsoft.Jet.OLEDB.4.0">



Error: value of type string cannot be converted to system.data.oledb.oledbconnection


如何更改连接字符串以打开连接?



Error: value of type string cannot be converted to system.data.oledb.oledbconnection


How should I change the connectionstring to open the connection?

推荐答案



<connectionStrings>
   <add name="MainConnStr" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\vana\Anil\kan.mdb;"/>
  </connectionStrings>




并在.aspx.vb

strconnection =新的OleDbConnection(ConfigurationManager.ConnectionStrings("MainConnStr").ConnectionString)
strconnection.Open()




and in .aspx.vb

strconnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("MainConnStr").ConnectionString)
strconnection.Open()


这篇关于如何通过web.config连接到Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 16:42