我想從我的數據庫的表列中插入所有數據,但現在即時通訊只獲取一行/或簡而言之,我想要獲取所有數據列而不是隻有1行,使用此代碼IM:如何插入所有數據,而不是隻獲得1行
Try
For i = 0 To dt.Rows.Count - 1
networkconn.Open()
Dim cmd As New OdbcCommand("INSERT INTO networkdatabase.table1(data,result) values('" & dt.Rows(0).Item("data").ToString & "','" & dt.Rows(0).Item("result").ToString() & "')", networkconn)
cmd.ExecuteNonQuery()
networkconn.close
Next
Catch ex As Exception
End Try
這是我的表
+------------+----------+
| data | result |
+------------+----------+
| 1234567890 | PASSED |
| Test | PASSED |
| SAMPLE | FAILED |
| test | FAILED |
| GGGGGG | PASSED |
| 1111111111 | PASSED |
| XXXXXXXXXX | PASSED |
+------------+----------+
我的輸出
+------------+----------+
| data | result |
+------------+----------+
| 1234567890 | PASSED |
+------------+----------+
期望輸出
+------------+----------+
| data | result |
+------------+----------+
| 1234567890 | PASSED |
| Test | PASSED |
| SAMPLE | FAILED |
| test | FAILED |
| GGGGGG | PASSED |
| 1111111111 | PASSED |
| XXXXXXXXXX | PASSED |
+------------+----------+
使用[循環](http://www.dotnetperls.com/for-vbnet) – HengChin 2014-10-02 06:05:49
那麼怎麼樣:'爲每行作爲DataRow在dt.Rows'? – 2014-10-02 06:42:35
我該怎麼做? – 2014-10-02 07:07:38