Web.config文件里该怎么写?读取连接的代码又该怎么写?
怎么把Web.config里面的身份验证改成SSPI?
在Petshop4.0的工程里Web.config里我也找不到连接配置,是不是放到其他config了?怎么指定
configurationManager?
怎么把Web.config里面的身份验证改成SSPI?
在Petshop4.0的工程里Web.config里我也找不到连接配置,是不是放到其他config了?怎么指定
configurationManager?
调试欢乐多
比如
<connectionStrings>
<!--SQL数据库连接字符串" -->
<add name="SQLConnectionString" connectionString="Data Source=user012;Initial Catalog=MyShop;User ID=sa;Password=sa" providerName="System.Data.SqlClient"/>
</connectionStrings>
那么
string constr=ConfigurationManager.connectionStrings("SQLConnectionString").contionString;
<appSettings>
<add key="ConnectionString" value="Data Source=localhost;POOLING=FALSE;database=databasemanage;User ID=sa;Password=sa"/>
<add key="AdminTable" value="admintable"/>
</appSettings>
这种呢?
还有就是你要是不会写连接字符串,给你一个网站www.connectionstrings.com你可以找到任何一种数据库的连接字符串,还有一种简单的方法就是用一个SqlDataSource控件图形化的操作,然后就可以再web.config中找到刚配置好的连接字符串。如何读取连接字符串,见#1楼的。
登陆界面或是其他界面制定的loginurl界面会丢失图片路径小弟不才,曾经见过代码,不过还是没实现,还望各位前辈指点~
Data Source = .//主机名 。本机可以用点
DataBase =HIC 数据库名字
uid 数据库用户名。 pwd 是密码
调用时
----------------
string constr = ConfigurationManager.AppSettings["constr"];
SqlConnection mycon = new SqlConnection(constr );
mycon.Open();
</system.web>
//----这个路径是你同意没有登录的用户可以访问的资源
<location path="Image">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
承蒙指教..
只是image前不用加~/么?
<appSettings>
<add key="ConnectionString" value="Data Source=localhost;POOLING=FALSE;database=databasemanage;User ID=sa;Password=sa"/>
<add key="AdminTable" value="admintable"/>
</appSettings>
这个要怎么改成windows验证的?
-----------------------
<add key="ServerName" value="192.168.1.21\sql2005" />
<add key="Database" value="tjzx" />
<add key="IntegrateSecurity" value="false" />
<appSettings>
<add key="ConnectionString" value="Data Source=localhost;POOLING=FALSE;database=databasemanage;User ID=sa;Password=sa"/>
<add key="AdminTable" value="admintable"/>
</appSettings> 路径\Admin2005\date\databasemanage.mdf
我要怎么修改?
<configuration>
<appSettings>
<add key="SqlCnStr" value="server=192.168.0.11;database=Data;uid=sa;pwd=6543219" />
</appSettings>
红色部分一定要写对哦。
使用的时候这样。
Dim Cnstr As String
Cnstr = ConfigurationManager.AppSettings("sqlcnstr")
如果这些你都写对的,你把你的错误说明发来看看,是不是你的数据库没有允许远程连接??
当为false时,将在连接中指定用户ID和密码。
当为true时,将使用当前的Windows帐户凭据进行身份验证。
可识别的值为true、false、yes、no以及与true等效的sspi。==============指你使用windows自带的安全验证机制,这时你不用加uid和password也可以打开数据库
如果你没有那一句的话,就必须在联接字符串里写上uid=sa;password=00;
否则你不能打开数据库这种东西网上一大把