一个页面(一个greadview ,一 个标签显示成功还是失败)
Default.aspx.cs 叶面代码:
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
DataSet myData = new DataSet();
string cmd = "SElECT * FROM login";
myData = SqlHelper.ExecuteDataset(SqlHelper.CONN_STRING_LC, CommandType.Text, cmd);
GridView1.DataSource = myData.Tables[0];
GridView1.DataBind();
Label1.Text = "连接成功";
}
catch (Exception excp)
{
Label1.Text = excp.Message.ToString();
}
}
}web.Config代码
<add name ="CONN_STRING_LC" connectionString="server=QQ;database=lianxi;uid=sa;pwd=;"/>sqlhelper 里面自己添加个字段
public static string CONN_STRING_LC = System.Configuration.ConfigurationSettings.AppSettings["CONN_STRING_LC"];为什么结果就是 “ 值不能为空。 参数名:connectionString”
Default.aspx.cs 叶面代码:
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
DataSet myData = new DataSet();
string cmd = "SElECT * FROM login";
myData = SqlHelper.ExecuteDataset(SqlHelper.CONN_STRING_LC, CommandType.Text, cmd);
GridView1.DataSource = myData.Tables[0];
GridView1.DataBind();
Label1.Text = "连接成功";
}
catch (Exception excp)
{
Label1.Text = excp.Message.ToString();
}
}
}web.Config代码
<add name ="CONN_STRING_LC" connectionString="server=QQ;database=lianxi;uid=sa;pwd=;"/>sqlhelper 里面自己添加个字段
public static string CONN_STRING_LC = System.Configuration.ConfigurationSettings.AppSettings["CONN_STRING_LC"];为什么结果就是 “ 值不能为空。 参数名:connectionString”
public static string CONN_STRING_LC = System.Configuration.ConfigurationSettings.AppSettings["CONN_STRING_LC"];