本文整理汇总了C#中DataAccess.excute方法的典型用法代码示例。如果您正苦于以下问题:C# DataAccess.excute方法的具体用法?C# DataAccess.excute怎么用?C# DataAccess.excute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataAccess
的用法示例。
在下文中一共展示了DataAccess.excute方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: load
public void load()
{
DataAccess data = new DataAccess();
data.Connection();
string sqlcom = "select goodsid,goodsname,goodsprice,goodssort,connectpeople,phone from [Goods] ";
SqlCommand cmd = data.excute(sqlcom);
DataSet ds = data.Fill(cmd);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
示例2: GridView1_PageIndexChanging
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
DataAccess data = new DataAccess();
data.Connection();
string sqlcom = "select goodsid,goodsname,goodsprice,goodssort,connectpeople,phone from [Goods] ";
SqlCommand cmd = data.excute(sqlcom);
DataSet ds = data.Fill(cmd);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
示例3: GridView1_RowDeleting
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int num = e.RowIndex;
DataAccess data = new DataAccess();
data.Connection();
DataTable dt=new DataTable();
string godid = GridView1.Rows[num].Cells[0].Text.ToString();
string sqlcom = "delete from [Goods] where goodsid='" + godid + "'";
SqlCommand cmd = data.excute(sqlcom);
Response.Write("<script language='javascript'>alert('删除成功!')</script>");
load();
}
示例4: Button1_Click1
protected void Button1_Click1(object sender, System.EventArgs e)
{
if (txtUser.Text.Trim() == "" || txtPwd.Text.Trim() == "")
{
lbInfo.Text = "请你务必填写必要的项!";
}
else if (txtPwd.Text.Trim() != txtPwdR.Text.Trim())
lbInfo.Text = "两次密码不一致,请核实!";
else
{
DataAccess data = new DataAccess();
data.Connection();
String str1 = "SELECT * FROM [User] where Username='" + txtUser.Text.Trim() + "'";
SqlCommand comm = data.excute(str1);
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(comm);
sda.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
lbInfo.Text = "你注册的用户名已经被别人注册,请改其它的名字注册";
}
else
{
try
{
String str = "INSERT INTO [User] (Username,Uemail,Upassword) VALUES ('" + txtUser.Text.Trim() + "','" + txtMail.Text.Trim() + "','" + txtPwd.Text.Trim() + "')";
SqlCommand com = data.excute(str);
}
catch (Exception eb)
{
eb.Message.Clone();
}
Response.Redirect("Default.aspx");
}
}
}
示例5: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
goodsid = Convert.ToInt32(Request.QueryString["id"].ToString());
DataAccess data = new DataAccess();
data.Connection();
string a = DropDownList1.SelectedItem.Text;
string name = Session["Username"].ToString();
string filepath = HttpContext.Current.Server.MapPath("~/Images/");
string filefullname = filepath + FileUpload1.FileName;
string filelujing = "\\Images\\" + FileUpload1.FileName;
FileUpload1.SaveAs(filefullname);//获取图片物理地址D:\My Documents\Visual Studio 2013\WebSites\WebSite1\Images
sqlcom = "update [Goods] set [goodsname]='" + gName.Text.Trim() + "',[images]='" + filelujing + "',[goodsprice]='" + gMoney.Text.Trim() + "',[goodssort]='" + a + "',[connectpeople]='" + cname.Text.Trim() + "',[phone]='" + phone.Text.Trim() + "',[Username]='" + name + "',[details]='" + details.Text.Trim() + "' where goodsid=" + goodsid;
SqlCommand cmd = data.excute(sqlcom);
Response.Redirect("person.aspx");
}
示例6: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
if (Session["Username"] == null)
{
Response.Write("<script language='javascript'>alert('没有登录不能评论')</script>");
return;
}
string time = DateTime.Now.ToLongDateString();
DataAccess data = new DataAccess();
data.Connection();
string Username = Session["Username"].ToString();
int id = Convert.ToInt32(Request.QueryString["id"].ToString());
string sqlcom = "insert into [message] (mescontent,Username,goodsid,mestime) values ('" + Message.Text.Trim() + "','" + Username + "','" + id + "','" + time + "')";
SqlCommand cmd = data.excute(sqlcom);
Message.Text = "";
load();
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
String[] str = new String[] { "str1", "str2", "str3", "str4" };
DataList[] list = new DataList[] { DataEle, DataBook, DataLife, DataOther };//创建datalist控件数组
DataAccess data = new DataAccess();
data.Connection();//链接数据库
str[0] = "SELECT goodsid,goodsname,goodsprice,images FROM [Goods] where goodssort='电子产品' order by goodsid desc";
str[1] = "SELECT goodsid,goodsname,goodsprice,images FROM [Goods] where goodssort='书籍' order by goodsid desc";
str[2] = "SELECT goodsid,goodsname,goodsprice,images FROM [Goods] where goodssort='生活用品' order by goodsid desc";
str[3] = "SELECT goodsid,goodsname,goodsprice,images FROM [Goods] where goodssort='其它' order by goodsid desc";
for (int i = 0; i < 4; i++)
{
SqlCommand cmd = data.excute(str[i]);//执行sql语句;
DataSet ds = data.Fill(cmd);
list[i].DataSource = ds.Tables[0].DefaultView;
list[i].DataBind();//数据绑定显示;
}
}
示例8: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
DataAccess data = new DataAccess();
string sqlcom = "select * from [Admin] where Adminid='" + FunStr(Adminname.Text.Trim()) + "'and Apassword='" + FunStr(Adminpwd.Text.Trim()) + "'";
data.Connection();
SqlCommand cmd = data.excute(sqlcom);
DataSet ds = data.Fill(cmd);
if (ds.Tables[0].Rows.Count > 0)
{
Session["Adminid"] = Adminname.Text.Trim();
Response.Redirect("AdminDefault.aspx");
}
else
{
Label1.Text = "您的用户名或密码错误";
Adminname.Text = "";
}
}
示例9: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
DataAccess data = new DataAccess();
data.Connection();
string sqlcom = "select * from [User] where Username='" + Username.Text.Trim() + "'and Upassword='" + userpassword.Text.Trim() + "'";
SqlCommand cmd = data.excute(sqlcom);
DataSet ds = data.Fill(cmd);
if (ds.Tables[0].Rows.Count > 0)
{
Session["Username"] = Username.Text.Trim();
Response.Redirect("person.aspx");
}
else
{
Label1.Text = "您的用户名或密码错误";
Username.Text = "";
}
}
示例10: DataList1_ItemCommand
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.Item.ItemIndex != -1 && e.CommandName == "DRdel")//判断索引和CommandName
{
int godid = Convert.ToInt32(MarketDetailDl.DataKeys[e.Item.ItemIndex].ToString());
DataAccess data = new DataAccess();
data.Connection();
string sqlcom = "delete from [Goods] where goodsid='" + godid + "'";
SqlCommand cmd = data.excute(sqlcom);
Response.Write("<script language='javascript'>alert('删除成功!')</script>");
load();
}
if (e.Item.ItemIndex != -1 && e.CommandName == "DRdel1")//判断索引和CommandName
{
int godid = Convert.ToInt32(MarketDetailDl.DataKeys[e.Item.ItemIndex].ToString());
Response.Redirect("Update.aspx?id=" + godid + "");
}
}
示例11: DataPage
public void DataPage(string sqlcom, DataList MarketDetailDl, Label lblCurPage, Label lblTnum, Label lblEachPage, HyperLink lnkFirst, HyperLink lnkLast, HyperLink lnkPrev, HyperLink lnkNext, HttpRequest Request)
{
DataAccess data = new DataAccess();
data.Connection();
SqlCommand cmd = data.excute(sqlcom);
DataSet ds = data.Fill(cmd);
MarketDetailDl.DataSource = ds.Tables[0].DefaultView;
MarketDetailDl.DataBind();
PagedDataSource objPage = new PagedDataSource();//创建分页类
objPage.DataSource = ds.Tables["Table"].DefaultView;//设置数据源
objPage.AllowPaging = true;
objPage.PageSize = 5;
if (Request.QueryString["Page"] != null)
{
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
CurPage = Math.Min(CurPage, objPage.PageCount);
CurPage = Math.Max(CurPage, 1);
}
else
CurPage = 1;
objPage.CurrentPageIndex = CurPage - 1;
TotalPage = objPage.PageCount;
Tnum = objPage.DataSourceCount;
EachPage = objPage.Count;
lblCurPage.Text = "第 " + CurPage.ToString() + " / " + TotalPage.ToString() + " 页";
lblTnum.Text = "共: " + Tnum + " 条记录";
lblEachPage.Text = "每页有: " + EachPage.ToString() + " 条记录";
if (objPage.CurrentPageIndex != 0)
lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage-CurPage +1);
if (objPage.CurrentPageIndex != TotalPage - 1)
lnkLast.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(TotalPage);
if (!objPage.IsFirstPage)
lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
if (!objPage.IsLastPage)
lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
MarketDetailDl.DataSource = objPage;
MarketDetailDl.DataBind();
}
示例12: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] == null)
Response.Redirect("Default.aspx");
int id = Convert.ToInt32(Request.QueryString["id"].ToString());
DataAccess data = new DataAccess();
data.Connection();
string sqlcom = "SELECT goodsname,goodsprice,phone,images,details FROM [Goods] where goodsid=" + id;
SqlCommand cmd = data.excute(sqlcom);
DataSet ds = data.Fill(cmd);
gName.Text = ds.Tables[0].Rows[0][0].ToString();
money.Text = ds.Tables[0].Rows[0][1].ToString();
tel.Text = ds.Tables[0].Rows[0][2].ToString();
Image1.ImageUrl = ds.Tables[0].Rows[0][3].ToString();
Mes.Text = ds.Tables[0].Rows[0][4].ToString();
string sqlcom1 = "select mescontent, Username, mestime from [message] where goodsid=" + id;
DataFill ds1 = new DataFill();
ds1.DataPage(sqlcom1, DataList1, lblCurPage, lblTnum, lblEachPage, lnkFirst, lnkLast, lnkPrev, lnkNext, Request);
}
示例13: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
string time = DateTime.Now.ToLongDateString();
DataAccess data = new DataAccess();
data.Connection();
string a = DropDownList1.SelectedItem.Text;
string name = Session["Username"].ToString();
string filepath = HttpContext.Current.Server.MapPath("~/Images/");
string filefullname = filepath + FileUpload1.FileName;
string filelujing = "\\Images\\" + FileUpload1.FileName;
FileUpload1.SaveAs(filefullname);//获取图片物理地址D:\My Documents\Visual Studio 2013\WebSites\WebSite1\Images
if (gName.Text.Trim() == "" || cname.Text.Trim() == "")
{
Response.Write("<script language='javascript'>alert('商品名称或联系人不能为空')</script>");
return;
}
String str = "INSERT INTO [Goods] (goodsname,images,goodsprice,goodssort,connectpeople,phone,Username,details,datetime) VALUES ('" + gName.Text.Trim() + "','" + filelujing + "','" + gMoney.Text.Trim() + "','" + a + "','" + cname.Text.Trim() + "','" + phone.Text.Trim() + "','" + name + "','" + details.Text.Trim() + "','" + time + "')";
SqlCommand cmd = data.excute(str);
Response.Redirect("person.aspx");
}