| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 631 人关注过本帖
标题:ASP.NET(VB)如何转成ASP.NET(C#)
取消只看楼主 加入收藏
lin9576
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-12-23
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
ASP.NET(VB)如何转成ASP.NET(C#)
请问怎么把下面VB的for语句改成C#的,谢谢~~~~~~~~~~
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim intClassID As Integer = Convert.ToInt32(ddlstclass.SelectedItem.Value)
        Dim intCourseID As Integer = Convert.ToInt32(ddlstcourse.SelectedItem.Value)
        Dim intTeacherID As Integer = Convert.ToInt32(ddlstTea.SelectedItem.Value)
        Dim intTerm As String = TextBox1.Text
        Dim conn As New SqlConnection
        conn.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString").ConnectionString
        Dim i As Integer
        For i = 0 To gvstu.Rows.Count - 1
            Dim lbl1 As Label
            lbl1 = gvstu.Rows.Item(i).FindControl("Label1")
            Dim intStudentID As Integer = Convert.ToInt32(lbl1.Text)
            intStudentID = Convert.ToInt32(lbl1.Text)
            Dim strsql As String = "insert into Score(studenID,courseID,TeacherID,Term) values(" & intStudentID & "," & intCourseID & "," & intTeacherID & ",'" & intTerm & "')"
            Dim cmd As New SqlCommand(strsql, conn)
            conn.Open()
            cmd.ExecuteNonQuery()
            conn.Close()
        Next
    End Sub
搜索更多相关主题的帖子: Object 如何 
2012-01-18 16:38
快速回复:ASP.NET(VB)如何转成ASP.NET(C#)
数据加载中...
 
   



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

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