程序如下,想找大神帮忙看下数据库连接是否有问题,具体就是讲strFullname.Text等导入数据库rccp_account_application表,下面程序我写了1-2个text进行调试,但是失败了。
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;public partial class rccp_account_application : System.Web.UI.Page
{
public SqlConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
string strconn = "server=服务器名;database=数据库名;uid=用户名;pwd=密码";
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
DataSet ds = new DataSet();
string sql="SELECT * FROM rccp_account_application";
SqlDataAdapter dap = new SqlDataAdapter(sql,conn);
dap.Fill(ds);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string strFullname = txtFullname.Text;
string strShortname = txtShortname.Text;
string strdropdownlist1 = DropDownList1.Text;
string strdropdownlist2 = DropDownList2.Text;
string strdropdownlist3 = DropDownList3.Text;
string strdropdownlist4 = DropDownList4.Text;
string strArea = txtArea.Text;
string strAddress = txtAddress.Text;
string strCode = txtCode.Text;
string strPerson = txtPerson.Text;
string strDept = txtDept.Text;
string strPosition = txtPosition.Text;
string strTel = txtTel.Text;
string strFax = txtFax.Text;
string strPhone = txtPhone.Text;
string strMail = txtMail.Text;
string strWeb = txtWeb.Text;
string strdropdownlist5 = DropDownList5.Text;
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "insert into rccp_account_application(CompanyFullname,CompanyShortname) values(@CompanyFullname,@CompanyShortname)";
SqlParameter para = new SqlParameter("@CompanyFullname", SqlDbType.VarChar,255);
para.Value = txtFullname.Text;
cmd.Parameters.Add(para);
}}
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;public partial class rccp_account_application : System.Web.UI.Page
{
public SqlConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
string strconn = "server=服务器名;database=数据库名;uid=用户名;pwd=密码";
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
DataSet ds = new DataSet();
string sql="SELECT * FROM rccp_account_application";
SqlDataAdapter dap = new SqlDataAdapter(sql,conn);
dap.Fill(ds);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string strFullname = txtFullname.Text;
string strShortname = txtShortname.Text;
string strdropdownlist1 = DropDownList1.Text;
string strdropdownlist2 = DropDownList2.Text;
string strdropdownlist3 = DropDownList3.Text;
string strdropdownlist4 = DropDownList4.Text;
string strArea = txtArea.Text;
string strAddress = txtAddress.Text;
string strCode = txtCode.Text;
string strPerson = txtPerson.Text;
string strDept = txtDept.Text;
string strPosition = txtPosition.Text;
string strTel = txtTel.Text;
string strFax = txtFax.Text;
string strPhone = txtPhone.Text;
string strMail = txtMail.Text;
string strWeb = txtWeb.Text;
string strdropdownlist5 = DropDownList5.Text;
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "insert into rccp_account_application(CompanyFullname,CompanyShortname) values(@CompanyFullname,@CompanyShortname)";
SqlParameter para = new SqlParameter("@CompanyFullname", SqlDbType.VarChar,255);
para.Value = txtFullname.Text;
cmd.Parameters.Add(para);
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货