上のアドバイスが必要:この行で奇妙な配列の問題に.....私はSQLデータベースからデータを読んでいて、接続が発生したが、以下のエラーが発生し、この
{"Index was outside the bounds of the array."}
を:
TextBox2.Text = TextBox2.Text & sqRdr.GetValue(22) & vbCrLf
私のテーブルのすべての列を数えて、彼らが正確に(22)と判明したので、これを手伝ってください。
上のアドバイスが必要:この行で奇妙な配列の問題に.....私はSQLデータベースからデータを読んでいて、接続が発生したが、以下のエラーが発生し、この
{"Index was outside the bounds of the array."}
を:
TextBox2.Text = TextBox2.Text & sqRdr.GetValue(22) & vbCrLf
私のテーブルのすべての列を数えて、彼らが正確に(22)と判明したので、これを手伝ってください。
....
DR["ColumnName"]
SqlDataReaderののこの[文字列名]は次のようになります。
以下は...
Using con As System.Data.SqlClient.SqlConnection = New SqlConnection("YourConnection string")
con.Open()
Dim cmd As New SqlCommand()
Dim expression As String = "Parameter value"
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "Your Stored Procedure"
cmd.Parameters.Add("Your Parameter Name", SqlDbType.VarChar).Value = expression
cmd.Connection = con
Using dr As IDataReader = cmd.ExecuteReader()
'You code like ....dr["YourColumnName"]
If dr.Read() Then
End If
End Using
End Using
感謝します。 – Armaan
サンプルコードで 'は何を示してsqRdr.FieldCount'のでしょうか? –
sqRdr.GetValue(21) –
@JonSkeet the FieldCountが表示されます22 – Armaan