温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:小白留言板源码
当前文件:
XiaobaiLiuyanban/App_Code/liuyan.cs[2K,2009-6-12 11:59:24],打开代码结构图
XiaobaiLiuyanban/App_Code/liuyan.cs[2K,2009-6-12 11:59:24],打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Web; 5
using System.Web.Security; 6
using System.Web.UI; 7
using System.Web.UI.WebControls; 8
using System.Web.UI.WebControls.WebParts; 9
using System.Web.UI.HtmlControls; 10
using System.Data.SqlClient; 11
/// <summary> 12
/// liuyanban 的摘要说明 13
/// </summary> 14
//该源码下载自www.51aspx.com(51aspx.com) 15
16
public class liuyan 17
{ 18
private static SqlConnection _con; 19
public static SqlConnection getCon() 20
{ 21
if (_con == null) 22
{ 23
_con = new SqlConnection(ConfigurationManager.ConnectionStrings["getcon"].ConnectionString); 24
25
} 26
return _con; 27
} 28
public static void insert(string sub, string fbr, string mail, string qq, string phone,string ip, string address, string home, string img, string text) 29
{ 30
getCon(); 31
_con.Open(); 32
string str = "insert into message(m_name,m_subject,m_content,m_phone,m_add,m_qq,m_mail,m_http,m_face,m_ip,m_datetime) values(@name,@sub,@ct,@ph,@add,@qq,@mail,@http,@face,@ip,@date)"; 33
34
SqlCommand com = new SqlCommand(str,_con); 35
com.Parameters.Add("@name",SqlDbType.VarChar).Value=fbr; 36
com.Parameters.Add("@sub", SqlDbType.VarChar).Value = sub; 37
com.Parameters.Add("@ct", SqlDbType.Text).Value = text; 38
com.Parameters.Add("@ph", SqlDbType.VarChar).Value = phone; 39
com.Parameters.Add("@add", SqlDbType.VarChar).Value = address; 40
com.Parameters.Add("@qq", SqlDbType.VarChar).Value = qq; 41
com.Parameters.Add("@mail", SqlDbType.VarChar).Value = mail; 42
com.Parameters.Add("@http", SqlDbType.VarChar).Value = home; 43
com.Parameters.Add("@face", SqlDbType.VarChar).Value = img; 44
com.Parameters.Add("@ip", SqlDbType.VarChar).Value = ip; 45
com.Parameters.Add("@date", SqlDbType.DateTime).Value = DateTime.Now.ToString(); 46
try 47
{ 48
com.ExecuteNonQuery(); 49
} 50
catch (Exception e) 51
{ 52
throw e; 53
} 54
finally 55
{ 56
_con.Close(); 57
} 58
59
} 60
public static DataSet sel() 61
{ 62
getCon(); 63
string str = "select * from message order by m_datetime desc"; 64
SqlDataAdapter adapter = new SqlDataAdapter(str,_con); 65
DataSet ds = new DataSet(); 66
try{ 67
adapter.Fill(ds,"message"); 68
}catch(Exception e) 69
{ 70
throw e; 71
} 72
return ds; 73
} 74
75
76
} 77








}