Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何从VB代码中获取连接字符串?_Asp.net_Vb.net - Fatal编程技术网

Asp.net 如何从VB代码中获取连接字符串?

Asp.net 如何从VB代码中获取连接字符串?,asp.net,vb.net,Asp.net,Vb.net,我在web.config中有它,我需要从vb中使用它将其传递给变量: <connectionStrings> <clear/> <add name="SQL1" connectionString="..." providerName="System.Data.SqlClient"/> </connectionStrings> 您还需要添加导入系统。配置未在项目级别设置。您可以在System.Configuration中使用Config

我在web.config中有它,我需要从vb中使用它将其传递给变量:

<connectionStrings>
  <clear/>
  <add name="SQL1" connectionString="..." providerName="System.Data.SqlClient"/>
</connectionStrings>


您还需要添加导入系统。配置未在项目级别设置。

您可以在System.Configuration中使用ConfigurationManager


ConfigurationManager.ConnectionString(“cnnName”).ConnectionString

不起作用,请告诉我更改为ISys..或AsyncOp..或oter bull,这也不起作用!
System.Configuration.ConfigurationManager.ConnectionStrings["SQL1"].ConnectionString
System.Configuration.ConfigurationManager.ConnectionStrings["SQL1"].ConnectionString
System.Configuration.ConfigurationManager.ConnectionStrings["SQL1"].ToString();