login.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Web.Configuration;
using System.Data;
using System.Data.SqlClient;**
public class db
{
public static string connstring = "data source=localhost; Initial Catalog=user_login; integrated security=SSPI";
public static void Dosql(string sql)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = connstring;
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
}
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string user_name, user_pw, real_name, title, school, department, phone_number, email;
user_name = UserText.Text.Replace("'", "''");
user_pw = PassText.Text.Replace("'", "''");
real_name = NameText.Text.Replace("'", "''");
title = TitleText.Text.Replace("'", "''");
school = SchoolText.Text.Replace("'", "''");
department = DepartmentText.Text.Replace("'", "''");
phone_number = PhoneText.Text.Replace("'", "''");
email = EmailText.Text.Replace("'", "''");
string sql = "insert into user_info (user_name,user_pw,real_name,title,school,department,phone_number,email)values]('" + user_name + "','" + user_pw + "','" + real_name + "','" + title + "','" + school + "','" + department + "','" + phone_number + "','" + email + "')";
db.Dosql(sql);
Response.Write("<script language=javascript>alert('注册成功,请稍后登陆!');</script>");
}
private void CheckInput()
{
throw new NotImplementedException();
}
protected void UserText_TextChanged(object sender, EventArgs e)
{
}
}
<?xml version="1.0"?>
providerName="System.Data.SqlClient" />
求大神指导