SQL SELECT
Table_1の列を画面に表示する。
COBOL
VB.NET
Module Module1
Private myCNN As SqlClient.SqlConnection
Private myCmd As SqlClient.SqlCommand
Private myReader As SqlClient.SqlDataReader
Sub Main()
Try
Dim strCNN As String = "Data Source=localhost\SQLEXPRESS;" _
& "Initial Catalog=TEST;" _
& "Integrated Security=True"
myCNN = New System.Data.SqlClient.SqlConnection(strCNN)
myCNN.Open()
Console.WriteLine(myCNN.State.ToString)
myCmd = myCNN.CreateCommand
myCmd.CommandText = "SELECT * FROM Table_1"
myReader = myCmd.ExecuteReader
Do While myReader.Read()
Console.WriteLine(myReader.GetString(0) & " " & myReader.GetDecimal(1))
Loop
myCNN.Close()
Console.WriteLine(myCNN.State.ToString)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
End Module
| Open AAA 2 BBB 2 CCC 1 DDD 1 EEE 1 FFF 0 GGG 0 HHH 8 III 8 Closed |
お役に立てましたか?
IT、プログラミングのランキングサイトはこちらです。
最新記事の自動受信登録はこちらです。 |
![]() |
![]() |
![]() |
![]() |
| 固定リンク







コメント