| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 675 人关注过本帖
标题:急!请大侠赐教!再线等!
只看楼主 加入收藏
yaiba9089
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-4-23
收藏
 问题点数:0 回复次数:2 
急!请大侠赐教!再线等!

小弟一朋友明天毕业答辩,因没参加毕业设计对代码一窍不通,在下也只是一知半解,特向大侠请教,能给出代码的解释!!!

代码片段如下一共二个模块:

模块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

再次多谢各位大侠了!!!!

搜索更多相关主题的帖子: face 朋友 一窍不通 
2005-04-23 15:37
silvermoon
Rank: 1
等 级:新手上路
帖 子:188
专家分:0
注 册:2004-8-20
收藏
得分:0 
晕,代码倒不是很难,但是太多了

我是一棵菠菜~~菜菜菜菜菜~~~
2005-04-23 16:55
yaiba9089
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-4-23
收藏
得分:0 
自动生成的就不用说了!
主要是其他部分的!
2005-04-23 17:43
快速回复:急!请大侠赐教!再线等!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016649 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved