日期:2014-05-17 浏览次数:20435 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string SqlStr = System.Configuration.ConfigurationManager.AppSettings["conStr"];
SqlConnection con = new SqlConnection(SqlStr);
con.Open();
if (con.State == System.Data.ConnectionState.Open)
{
Response.Write("SQL Server 数据库连接成功!");
con.Close();
return;
}
if (con.State == System.Data.ConnectionState.Closed)
{
Response.Write("失败");
}
string strSqlCom = "insert into user(username,userpassword) values('shabi','12312');";
SqlCommand sqlcom = new SqlCommand(strSqlCom, con);
sqlcom.ExecuteNonQuery();
}
}