asp.net连接数据库
这是我打的代码:using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace liu
{
public partial class jj : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSelect_Click(object sender, EventArgs e)
{
if (this.txtName.Text != "")
{
string myStr = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection Conn = new SqlConnection(myStr);
Conn.Open();
string sqlStr = "select*from tblStudents where Name=@Name";
SqlCommand myCmd = new SqlCommand(sqlStr, Conn);
myCmd.Parameters.Add("@Name", SqlDbType.VarChar, 20).Value = this.txtName.Text.Trim();
SqlDataAdapter myDa = new SqlDataAdapter(myCmd);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
if (myDs.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = myDs;
GridView1.DataBind();
}
else
{
Response.Write("<script>alert('没有获得相关记录')</script>");
}
myDa.Dispose();
myDs.Dispose();
Conn.Close();
}
else
this.bind();
}
}
}
出现的问题是:倒数第4行的 this.bind();
“liu.jj”不包含“bind”的定义,并且找不到课接受类型为“liu.jj”的第一个参数的扩展方法“bind”(是否缺少using指令或程序集引用)
谁知道是什么问题,告诉下!问题解决了我加分!
追问:我不太清楚,刚学这个工具。 那 怎么写this.bind() 写在哪? 要是写有了,怎么用Using 引用?