显然是连接字符串没写对.自己查
http://connectionstrings.com/
http://connectionstrings.com/
解决方案 »
- 正则:如何匹配空格,换行符以外的所有字符,且字符长度在6-16位
- ◆常见的ifame问题请教◆
- 如何写DataGrid 中TextBox的TextChanged事件
- WebClient .DownloadData 出现乱码问题(C#)
- 做asp学asp.net的同志们,进来分享一下经验!怎么学好.net!
- treeview中滚动条的一个问题
- confirm怎么用?
- 关于短信方面的问题。。大家帮忙~来着有分
- 接触过在WEB.CONFIG中新建配置节的各类帮帮忙!!!
- 求解答
- 有一个网站!!数据库连接db.cs不想编译!怎么加密?
- 我正在使用vs2008,使用了listview控件,在模板里添加了一个HyperLink,想用findcontrol找到这个控件,为什么找不到,提示没有HyperLink3这个控件
string ConnectionString = "data source=localhost;initial catalog=DatabaseName;integrated security=SSPI;user ID=sa;password=123456";
public SqlDataReader GetList(string Sql)
{
string ConnectionString = "data source=localhost;initial catalog=DatabaseName;integrated security=SSPI;user ID=sa;password=123456";
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlCommand myCommand = new SqlCommand(Sql, myConnection); myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
return result;
}
{
protected string strconnection;
protected SqlConnection conn;
public Database()
{
strconnection = ConfigurationManager.ConnectionStrings["zilong"].ConnectionString;
}
protected void Open() //保护方法,打开连接
{ if (conn == null)
{
conn = new SqlConnection(strconnection);
}
if (conn.State.Equals(ConnectionState.Closed))
{
conn.Open();
}
}
public void Close()
{
if (conn.State.ToString() == "Open")
{
conn.Close();
}
}
public SqlDataReader GetList(string Sql)
{ Open();
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
return result;
}