本文介绍了关于数据库连接性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的应用程序在VB.net中,并且有一个clsdatabase
类.
在这种情况下,我有如下连接字符串的源代码.
Hello all,
My application is in VB.net and I am having one clsdatabase
class.
In that i am having source code like below for connection string.
con = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("strConString1"));
但是我想在C#中实现的同一件事...
我只是将其转换为
but the same thing i want to implement in C#...
I just converted that in to
con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings("strConString1"))
但执行时会吹错.
but it will blow error while execution.
Non-Invocable member.
System.Configuration.ConfigurationManager.AppSettings cannot be used like a method...
那我该怎么解决呢?
So how can i tackle that?
推荐答案
con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings("strConString1"))
成为
con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strConString1"])
System.Configuration.ConfigurationManager.AppSettings[keyName]
(方括号.)
瓦莱里.
(Square brackets.)
Valery.
这篇关于关于数据库连接性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!