返回首页

马亨德兰杀敌

回答

评论会员:游客 时间:2012/02/05
可以使用dr.read()或dr.HasRowscodepreSqlCommandmyCMD=newSqlCommand(spanclass="code-string""/spanspanclass="code-string"SELECTCategoryID,CategoryNameFROMCategories;"/span+spanclass="code-string""/spanspanclass="code-string"SELECTEmployeeID,LastNameFROMEmployees"/span,nwindConn);nwindConn.spanclass="code-keyword"Open/span(); SqlDataReadermyReader=myCMD.ExecuteReader(); do{Console.WriteLine(spanclass="code-string""/spanspanclass="code-string"\t{0}\t{1}"/span,myReader.GetName(spanclass="code-digit"0/span),myReader.GetName(spanclass="code-digit"1/span)); spanclass="code-keyword"while/span(myReader.spanclass="code-keyword"Read/span())Console.WriteLine(spanclass="code-string""/spanspanclass="code-string"\t{0}\t{1}"/span,myReader.GetInt32(spanclass="code-digit"0/span),myReader.GetString(spanclass="code-digit"1/span)); }spanclass="code-keyword"while/span(myReader.NextResult()); myReader.spanclass="code-keyword"Close/span();nwindConn.spanclass="code-keyword"Close/span();/pre/code
CPallini
评论会员:游客 时间:2012/02/05
你可以使用imgsrc=]的方法来实现这一行为
马亨德兰杀敌:SqlConnection的CON =新的SqlConnection("数据源= MAJ-056 \ SQLEXPRESS的初始目录=样品;集成安全性= TRUE");
&# 160; SqlCommand的CMD1 =新的SqlCommand("SELECT *从EXCEPTION_LOG TicketId ="Convert.ToInt64(TextBox1.Text)",CON);
con.Open()
 0; SqlDataReader的DR1 = cmd1.ExecuteReader()
  ; 如果(dr1.Read())
& #160;{
con.Close()
  ; SqlCommand的CMD2 =新的SqlCommand("删除EXCEPTION_LOG TicketId ="Convert.ToInt64(TextBox1.Text)",CON)
con.Open()
cmd2.ExecuteNonQuery()
con.Close()
SqlCommand的CMD3 =新的SqlCommand("插入到的delete_table值("Convert.ToInt64(TextBox1.Text)")",CON)
& #160;con.Open()
cmd3.ExecuteNonQuery()
con.Close()
}
其他
{
  ;con.Close()
SqlCommand的CMD =新的SqlCommand("从的delete_table选择* TicketId
="Convert.ToInt64(TextBox1.Text)",CON);  0; con.Open()
SqlDataReader的博士= cmd.ExecuteReader();
&# 160; 如果(dr.Read())
{
  ; ("有没有会话")
}
其他
{
& #160; ("中TicketID无效");
}
 60; con.Close()
}
con.Close();
评论会员:马亨德兰杀敌 时间:2012/02/05
编码:


使用系统;
使用System.Collections.Generic
使用System.Linq的;
使用的System.Web;
CSDN社区 -
使用System.Web.UI.WebControls;
使用System.Data.SqlClient的
使用System.Data;

公共部分类DeleteSample的System.Web.UI.Page
{
SqlConnection的CON =新的SqlConnection("数据源= MAJ-056 \ SQLEXPRESS的初始目录=采样;集成安全性= TRUE")
保护无效的Page_Load(对象发件人,EventArgs的五)
{

}
&# 160; 保护的无效LinkBut​​ton1_Click(对象发件人,EventArgs的五)
{
SqlCommand的CMD =新的SqlCommand("删除EXCEPTION_LOG TicketId
="Convert.ToInt64(TextBox1.Text)",CON); & #160; con.Open()
cmd.ExecuteNonQuery()
con.Close()
SqlCommand的CMD1 =新的SqlCommand("插入到的delete_table值("Convert.ToInt64(TextBox1.Text)")",CON)
con.Open()
&# 160;cmd1.ExecuteNonQuery()
con.Close()
}
保护无效中button1_Click(对象发件人,EventArgs的五)
{
SqlDataAdapter的DA =新的SqlDataAdapter("SELECT *从EXCEPTION_LOG TicketId ="Convert.ToInt64(TextBox1.Text)",CON)
的DataSet DS =新的DataSet();
da.Fill(DS)
  ; 如果(ds.Tables [0] Rows.Count> 0)
{
GridView1.DataSource = DS;
GridView1.DataBind()
}
其他
{
& #160;con.Open()
SqlCommand的CMD =新的SqlCommand("从的delete_table选择* TicketId
="Convert.ToInt64(TextBox1.Text)",CON); &# 160; SqlDataReader的博士= cmd.ExecuteReader();
如果(dr.Read())
&# 160; {
& #160; ("没有会话")
& #160; }
  ; 其他
{
&# 160; 回复于("无效");
}
  ; }
}
}

设计页面:
{C}