0

我有一个下一步按钮。

没有错误我只是想简化

Try
     lblcat.Text = ds.Tables("evaluation").Rows(cat)("QuestionCategory")
     txt1.Text = ds.Tables("evaluation").Rows(CurrentRow)("Question")
     txt2.Text = ds.Tables("evaluation").Rows(CurrentRow + 1)("Question")
     txt3.Text = ds.Tables("evaluation").Rows(CurrentRow + 2)("Question")
     txt4.Text = ds.Tables("evaluation").Rows(CurrentRow + 3)("Question")
     txt5.Text = ds.Tables("evaluation").Rows(CurrentRow + 4)("Question")
 Catch ex As Exception
 End Try

每次点击下一个按钮我的类别和问题都会改变。每次点击我也想保存在我的数据库中

Private Sub Save_commit()
 Dim con As New OleDbConnection
 Dim cmd As New OleDbCommand
 Dim sSQL As String = String.Empty
 Try
     'get connection string declared in the Module1.vb and assing it to conn variable
     con = New OleDbConnection(Get_Constring)
     con.Open()
     cmd.Connection = con
     cmd.CommandType = CommandType.Text
     'I just use the textbox tag property to idetify if the data is new or existing.
     sSQL = "INSERT INTO evaluationresult ([Com])" & _
             "  VALUES (?)"
     cmd.CommandText = sSQL
  cmd.Parameters.AddWithValue("@FacultyID", txtresult.Text)
     'cmd.Parameters.AddWithValue("@IDNumber", OleDbType.Numeric).Value
     'cmd.Parameters.AddWithValue("@Com", OleDbType.Numeric).Value
     ' cmd.Parameters.AddWithValue("@Know", OleDbType.Numeric).Value
     'cmd.Parameters.AddWithValue("@Teaching", OleDbType.Numeric).Value
     'cmd.Parameters.Addwithvallue("@man", OleDbType.Numeric).Value()
   'cmd.Parameters.AddWithValue("@ID", OleDbType.Numeric).Value
       cmd.ExecuteNonQuery()
     Catch ex As Exception
         MsgBox(ErrorToString)
     Finally
    con.Close()
     End Try
 End Sub

请改进

4

0 回答 0