日期:2014-05-18 浏览次数:20948 次
using System; using System.Collections; using System.Configuration; using System.Data; using System.Data.SqlClient; 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; public partial class _10_10 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection (System.Configuration.ConfigurationManager .ConnectionStrings["SQLCONN"].ConnectionString)) { conn.Open(); SqlDataAdapter sqldap = new SqlDataAdapter(); SqlCommand cmm = new SqlCommand(); cmm.Connection = conn; cmm.CommandType = CommandType.StoredProcedure; cmm.CommandText = "StoredProcedure1";//此处调用存储过程 cmm.Parameters.Add("wlpz", SqlDbType.NVarChar); cmm.Parameters.Add("wlms", SqlDbType.NVarChar); cmm.Parameters.Add("ydlx", SqlDbType.NVarChar); cmm.Parameters.Add("kw", SqlDbType.NVarChar); //cmm.Parameters.Add("ctitle", SqlDbType.NVarChar); cmm.Parameters["wlpz"].Value = wlpz.Text; cmm.Parameters["wlms"].Value = wlms.Text; cmm.Parameters["ydlx"].Value = ydlx.SelectedValue.ToString(); cmm.Parameters["kw"].Value = kw.SelectedValue.ToString(); //cmm.Parameters["ctitle"].Value = ContactTitle.Text; sqldap.SelectCommand = cmm; DataTable dt = new DataTable(); sqldap.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } } }