- 爱易网页
-
ASP.NET教程
- 数据插不进数据库,麻烦大家帮帮忙,多谢
日期:2014-05-17 浏览次数:20507 次
数据插不进数据库,麻烦大家帮帮忙,谢谢
下面是代码:
web.config:(配置文件)
<?xml version="1.0"?>
<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=服务器;Initial Catalog=testonline;User ID=sa;Password=密码"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
</system.web>
</configuration>
DB类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Security.Cryptography;
/// <summary>
///DB 的摘要说明
/// </summary>
public class DB
{
public SqlConnection getcon()
{
return new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
}
public int sqlex(string cmdstr)
{
SqlConnection con =getcon();
con.Open();
SqlCommand cmd = new SqlCommand(cmdstr,con);
try
{
cmd.ExecuteNonQuery();
return 1;
}
catch (Exception e)
{
return 0;
}
finally
{
con.Dispose();
}
}
public string getmd5(string strpwd)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] data = System.Text.Encoding.Default.GetBytes(strpwd);
byte[] md5data = md5.ComputeHash(data);
md5.Clear();
string str="";
for (int i = 0; i < md5data.Length - 1; i++)
{