ASP.net连SQL Server

来源:百度知道 编辑:UC知道 时间:2024/05/30 18:55:58
provider: SQL 网络接口, error: 26 - 定位指定的服务器/实例时出错
怎么解决啊?
ASP.net出的问题。
我装的是SQL Server2005 Development
VS2005.net Team(v2.0.50727)
计算机名是c
操作系统是XP Pro sp2

如果是数据库连接字串的问题,麻烦写个这样环境下的连接字串的标准示例好吗?我的连接字串是在web.config里的。谢了!
(我不太懂MSSQL,所以希望能比较具体)

在你里web.config里的<configuration>添加以下节点:
<appSettings>
<add key="constr" value="server=(local);uid=用户名名;pwd=密码;database=数据库名" />
</appSettings>

在需要连接数据库的代码页面(即应用程序的后台编码类页面,也即相应的***.aspx.cs页)中导入命名空间using System.Data.SqlClient;

运用SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["constr"]);
这行代码通过调用ConfigurationManager.AppSettings方法取得名为constr的配置字符串,将该字符串作为数据库连接字符串实例化一个数据库连接对象

下面的就不用讲了吧,该对数据库进行什么样的操作,自己根据需要去发挥吧

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace fweight
{
class op
{
//MD5加密
public string encode(string str)
{
string htext = "";

for (int i = 0; i < str.Length; i++)
{
htext = htext + (char)(str[i] + 10 -