ConnectionString属性尚未初始化VB.NET

时间:2013-06-22 23:00:02

标签: sql vb.net database-connection connection-string

我是VB.NET的初学者,我还没有深入了解它的功能。关于这个问题的大多数问题都与我能力的问题有很大关系。

这就是我将ConnectionString初始化为SQL DB的方式。

Dim connection As New OleDb.OleDbConnection
Dim provider As String
Dim source As String
provider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
source = "Data Source=|DataDirectory|ClientDatabase.mdb"
connection.ConnectionString = provider & source

过去六个月一直有效。为什么现在不呢?

我一直得到的错误是: ConnectionString属性尚未初始化。

通常当这出现时,它就像拼写错误的东西一样愚蠢。

1 个答案:

答案 0 :(得分:0)

MIssing \字符:

Dim connection As New OleDb.OleDbConnection
Dim provider As String
Dim source As String
provider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
source = "Data Source=|DataDirectory|\ClientDatabase.mdb"
connection.ConnectionString = provider & source

Connection String.Com