本文介绍了“public readonly default property”的参数太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

For Me.i = 0 to grvExcelData.Rows.Count - 1

使用dbSQL_cmd作为新的MySqlCommand()

'student_id = grvExcelData.Item(i,0 ).Value.ToString

student_id = grvExcelData.Rows.Item((i),0).ToString

Major = grvExcelData.Rows.Item(i,1)。 Value.ToString

分类= grvExcelData.Rows.Item(i,2).Value.ToString

Course_ID1 = grvExcelData.Rows.Item(i,3).Value。 ToString

Subject_Area1 = grvExcelData.Rows.Item(i,4).Value.ToString.ToLower

dbSQL_query =INSERT INTO course_assignment1 VALUES(?student_id,?Major,?分类,?Course_ID1,?Subject_Area1,?Course_ID2,?Subject_Area2,Course_ID3,?Subject_Area3,?Course_ID4,?Subject_Area4,?Course_ID5,?Subject_Area5,?Course_ID6,?Subject_Area6)+

复制品密钥更新名称=(student_id =?student_id,Major =?Major,分类=?分类,Course_ID1 =?Course_ID1,Subject_Area1 =?Subject_Area1,Course_ID2 =?Course_ID2,Subject_Area2 =?Subject_Area2,Course_ ID3 =?Course_ID3,Subject_Area3 =?Subject_Area3,Course_ID4 =?Course_ID4,Subject_Area4 =?Subject_Area4,Course_ID5 =?Course_ID5,Subject_Area5 =?Subject_Area5,Course_ID6 =?Course_ID6,Subject_Area6 =?Subject_Area6)

With dbSQL_cmd

.Parameters.AddWithValue(?student_id,student_id)

.Parameters.AddWithValue(?Major,Major)

。 Parameters.AddWithValue(?Classification,Classification)

.Parameters.AddWithValue(?Course_ID1,Course_ID1)

.Parameters.AddWithValue(?Subject_Area1,Subject_Area1 )

.Parameters.AddWithValue(?Course_ID2,Course_ID2)

.Parameters.AddWithValue(?Course_ID3,Course_ID3)

。 Parameters.AddWithValue(?Course_ID4,Course_ID4)

.Parameters.AddWithValue(?Course_ID5,Course_ID5)

.Parameters.AddWithValue(?Course_ID6,Course_ID6 )

.Parameters.AddWithValue(?Subject_Area2,Subject_Area2)

.Parameters.AddWithValue(?Subject_Area3,Subject_Area3)

.Parameters.AddWithValue(?Subject_Area4,Subject_Area4)

.Parameters.AddWithValue(?Subject_Area5,Subject_Area5)

。参数.AddWithValue(?Subject_Area6,Subject_Area6)

.CommandText = dbSQL_query

.Connection = dbSQL_con

.CommandType = CommandType.Text

结束

dbSQL_cmd.ExecuteNonQuery()

结束使用

下一步

For Me.i = 0 To grvExcelData.Rows.Count - 1
Using dbSQL_cmd As New MySqlCommand()
'student_id = grvExcelData.Item(i, 0).Value.ToString
student_id = grvExcelData.Rows.Item((i), 0).ToString
Major = grvExcelData.Rows.Item(i, 1).Value.ToString
Classification = grvExcelData.Rows.Item(i, 2).Value.ToString
Course_ID1 = grvExcelData.Rows.Item(i, 3).Value.ToString
Subject_Area1 = grvExcelData.Rows.Item(i, 4).Value.ToString.ToLower
dbSQL_query = "INSERT INTO course_assignment1 VALUES (?student_id, ?Major, ?Classification, ?Course_ID1,?Subject_Area1,?Course_ID2,?Subject_Area2,Course_ID3,?Subject_Area3,?Course_ID4,?Subject_Area4,?Course_ID5,?Subject_Area5,?Course_ID6,?Subject_Area6) " +
" on duplicate key update name=(student_id=?student_id, Major=?Major, Classification=?Classification,Course_ID1=?Course_ID1,Subject_Area1=?Subject_Area1,Course_ID2=?Course_ID2,Subject_Area2=?Subject_Area2,Course_ID3=?Course_ID3,Subject_Area3=?Subject_Area3,Course_ID4=?Course_ID4,Subject_Area4=?Subject_Area4,Course_ID5=?Course_ID5,Subject_Area5=?Subject_Area5,Course_ID6=?Course_ID6,Subject_Area6=?Subject_Area6)"
With dbSQL_cmd
.Parameters.AddWithValue("?student_id", student_id)
.Parameters.AddWithValue("?Major", Major)
.Parameters.AddWithValue("?Classification", Classification)
.Parameters.AddWithValue("?Course_ID1", Course_ID1)
.Parameters.AddWithValue("?Subject_Area1", Subject_Area1)
.Parameters.AddWithValue("?Course_ID2", Course_ID2)
.Parameters.AddWithValue("?Course_ID3", Course_ID3)
.Parameters.AddWithValue("?Course_ID4", Course_ID4)
.Parameters.AddWithValue("?Course_ID5", Course_ID5)
.Parameters.AddWithValue("?Course_ID6", Course_ID6)
.Parameters.AddWithValue("?Subject_Area2", Subject_Area2)
.Parameters.AddWithValue("?Subject_Area3", Subject_Area3)
.Parameters.AddWithValue("?Subject_Area4", Subject_Area4)
.Parameters.AddWithValue("?Subject_Area5", Subject_Area5)
.Parameters.AddWithValue("?Subject_Area6", Subject_Area6)
.CommandText = dbSQL_query
.Connection = dbSQL_con
.CommandType = CommandType.Text
End With
dbSQL_cmd.ExecuteNonQuery()
End Using
Next

推荐答案

dbSQL_query = "INSERT INTO course_assignment1 VALUES (?student_id, ?Major, ?Classification, ?Course_ID1,?Subject_Area1,?Course_ID2,?Subject_Area2,Course_ID3,?Subject_Area3,?Course_ID4,?Subject_Area4,?Course_ID5,?Subject_Area5,?Course_ID6,?Subject_Area6) " +



尝试:


Try:

dbSQL_query = "INSERT INTO course_assignment1 VALUES (?student_id, ?Major, ?Classification, ?Course_ID1,?Subject_Area1,?Course_ID2,?Subject_Area2,?Course_ID3,?Subject_Area3,?Course_ID4,?Subject_Area4,?Course_ID5,?Subject_Area5,?Course_ID6,?Subject_Area6) " +


这篇关于“public readonly default property”的参数太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 01:34