无法将类型“System.Data.SqlClient.SqlConnection”隐式转换为“string"

yu6325862 yu6325862 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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 lxoo
{
public partial class _Default : System.Web.UI.Page
{


SqlConnection strConl;
SqlCommand strCom;
string strCon = "Data Source=.;Database=master;Uid=sa;Pwd=yu";


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
}

}

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
bind();
}

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string strSql = "delete from ygInfo where id = '" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
strCon = new SqlConnection(strCon );
strCom = new SqlCommand (strSql ,strCon );
strCon .open();
strCom .EndExecuteNonQuery ();
strCon .close();
bind();
}
public void bind ()
{

string strSql = "select * from ygInfo";
strCon = new SqlConnection (strCon );
SqlDataAdapter da = new SqlDataAdapter (strSql ,strCon );
DataSet ds = new DataSet ();
strCon .open();
da.Fill (ds,ygInfo);
GridView1 .DataSource = ds;
GridView1 .DataKeyNames = new string []{"id"};
GridView1 .DataBind ();
}

}
}
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
yu6325862
.NET社区 62,272 成员 668,968 内容