我的应用程序未读取Connections字符串 [英] Connections String is not being read by my application
本文介绍了我的应用程序未读取Connections字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个connetionstring名称dbInvoiceSQLExp我可以在使用向导创建数据集的同时在列表中看到它.但是当我运行程序时,它在
上显示错误
Hi,
I have a connetionstring name dbInvoiceSQLExp I can see this in the list while making dataset using the wizard. But when I run the program, it gives error on
Me._connection.ConnectionString = Global.Inventory_Manager.My.MySettings.Default.dbInvoiceSQLExp
说dbInvoiceSQLExp不是Inventory_Manager的成员
如何删除此CS并添加一个具有相同名称的新CS?或其他解决问题的方法?
谢谢
saying dbInvoiceSQLExp is not a member of Inventory_Manager
How can I remove this cs and add a new one with the same name? or any other way to resolve the issue?
Thanks
推荐答案
在app.config文件中
In app.config file
<connectionStrings>
<add name="MyConnect" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database\Data.mdb" providerName="System.Data.OleDb" />
</connectionStrings>
在您的类文件中添加名称空间
in your class file add namespace
Imports System.Configuration
在您的方法下,编写以下代码..
under your method write following code..
Private Sub MakeConnection()
Try
Dim strConnectionString As String
strConnectionString = ConfigurationManager.ConnectionStrings("MyConnect").ConnectionString
If strConnectionString Is Nothing Then
Throw New Exception("Please Check Connection")
Else
con = New OleDbConnection(strConnectionString)
cmd = New OleDbCommand()
cmd.Connection = con
End If
Catch ex As Exception
Throw ex
End Try
End Sub
你好-
也许这个网站可以帮助您:
http://www.connectionstrings.com/
Hi there--
Maybe this site can help:
http://www.connectionstrings.com/
这篇关于我的应用程序未读取Connections字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文