小弟一朋友明天毕业答辩,因没参加毕业设计对代码一窍不通,在下也只是一知半解,特向大侠请教,能给出代码的解释!!!
代码片段如下一共二个模块:
模块1:
Public Class lian_xi_wo_men
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
End Sub
End Class
模块2:
Public Class liu_lan_da_yi
Inherits System.Web.UI.Page
Protected WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Protected WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Protected WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Protected WithEvents DataSet21 As gh_card.DataSet2
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.DataSet21 = New gh_card.DataSet2
CType(Me.DataSet21, System.ComponentModel.ISupportInitialize).BeginInit()
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.InsertCommand = Me.SqlInsertCommand1
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "Question_answer", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("UserId", "UserId"), New System.Data.Common.DataColumnMapping("UserQuestion", "UserQuestion"), New System.Data.Common.DataColumnMapping("adminId", "adminId"), New System.Data.Common.DataColumnMapping("answer", "answer"), New System.Data.Common.DataColumnMapping("Riqi", "Riqi")})})
'
'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "INSERT INTO Question_answer (UserId, UserQuestion, adminId, answer, Riqi) VALUES " & _
"(@UserId, @UserQuestion, @adminId, @answer, @Riqi); SELECT UserId, UserQuestion," & _
" adminId, answer, Riqi FROM Question_answer"
Me.SqlInsertCommand1.Connection = Me.SqlConnection1
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UserId", System.Data.SqlDbType.VarChar, 20, "UserId"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UserQuestion", System.Data.SqlDbType.VarChar, 200, "UserQuestion"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@adminId", System.Data.SqlDbType.VarChar, 20, "adminId"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@answer", System.Data.SqlDbType.VarChar, 200, "answer"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Riqi", System.Data.SqlDbType.DateTime, 8, "Riqi"))
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "data source=w6;initial catalog=user;persist security info=False;user id=sa;passwo" & _
"rd=;workstation id=W6;packet size=4096"
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT UserId, UserQuestion, adminId, answer, Riqi FROM Question_answer WHERE (Us" & _
"erId <> '') AND (UserQuestion <> '') AND (adminId <> '') AND (answer <> '') AND " & _
"(DATEDIFF(day, Riqi, GETDATE()) < 14)"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
'
'DataSet21
'
Me.DataSet21.DataSetName = "DataSet2"
Me.DataSet21.Locale = New System.Globalization.CultureInfo("zh-CN")
CType(Me.DataSet21, System.ComponentModel.ISupportInitialize).EndInit()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
'时间判断
If Not IsPostBack Then
SqlDataAdapter1.Fill(DataSet21)
DataGrid1.DataBind()
End If
End Sub
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
End Sub
End Class
再次多谢各位大侠了!!!!