1
我需要逐行閱讀表中的一列,然後我需要存儲這個然後調用過程,以使用vb.net插入數據到不同的列。逐行閱讀vb.net
我已經創建了數據庫連接,我知道如何調用過程 ,但我不確定如何在循環中讀取,然後將其分配給變量以在存儲過程中調用它。
Dim drDocs As SqlClient.SqlDataReader
Dim cmdDocs As SqlClient.SqlCommand
Dim Doc As Long
Dim l As Long
Using conn As New SqlConnection(DBpath)
cmdDocs = New SqlClient.SqlCommand("Select (RecordID) from DocID", conn)
drDocs = cmdDocs.ExecuteReader
Do While drDocs.Read
'need it read each row in that field and hold value'
Loop
drDocs.Close()
cmdDocs.Dispose()
If Doc Then
cmdDocs = New SqlClient.SqlCommand("Insert_Doc", conn)
cmdDocs.CommandType = CommandType.StoredProcedure
cmdDocs.Parameters.Add("path", SqlDbType.NVarChar).Value =need to put hold value from reading that cloumn row by row
End If
End If
'從DocID'中選擇Max(RecordID)將始終只返回1行。你知道嗎? –
那麼如何讓它通過行循環來獲取值然後使用它來存儲,以便呼叫過程可以調用它 – kenmru