form
源码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;
using System.Reflection;
namespace WindowsApplication2
{
public partial class delete : DevExpress.XtraEditors.XtraForm
{
public delete()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("是否删除该行?", "Confirm Message", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
String MyConn = "server=localhost.;database=M10;integrated security=SSPI";
SqlConnection MyConnection = new SqlConnection(MyConn);
string MyDelete = "Delete from M_task_001 where FID=" + textBox1.Text;
SqlCommand MyCommand = new SqlCommand(MyDelete, MyConnection);
try
{
MyConnection.Open();
MyCommand.ExecuteNonQuery();
MyConnection.Close();
textBox1.Text = "";
MessageBox.Show("成功删除信息!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}