using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class lx2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connStr = System.Configuration.ConfigurationSettings.AppSettings[ "connString "];
SqlConnection myConnection = new SqlConnection(connStr);
string queryStr = "select * from DA ";
22行 SqlDataAdapter myDataAdapter = new SqlDataAdapter(queryStr.myConnection);
}
}
我是一个新手,刚刚学习ASP.NET,在练习ADO.NET数据库连接时出了些问题请大家帮帮我好吗?
错误是:编译器错误信息: CS0117: string并不包含myConnection的定义
------解决方法--------------------------------------------------------
SqlDataAdapter myDataAdapter = new SqlDataAdapter(queryStr.myConnection);
应是
SqlDataAdapter myDataAdapter = new SqlDataAdapter(queryStr, myConnection);
你把逗号写成了点了, 系统判断还以为myConnection是queryStr的成员, 所以出现这样的编译错误
------解决方法--------------------------------------------------------
楼上正解