0
这里是我的工作:获取与VB .NET从sqlserver的数据库记录
Dim connstr = "data source=mydatasource;initial catalog=gcs_dw;persist security info=True;user id=myuser;password=mypassword;Asynchronous Processing=True"
Dim sqlquery = "SELECT * FROM Customer WHERE CITY = 'Anytown'"
Dim connection As SqlConnection = New SqlConnection(connstr)
connection.Open()
Dim command As SqlCommand = connection.CreateCommand()
command.CommandText = sqlquery
Dim reader As SqlDataReader = command.ExecuteReader()
reader.Read()
Console.WriteLine(reader.ToString)
connection.Close()
Console.Read()
正如你所看到的,我试图以显示查询结果的命令行,目前所有它显示的是“System.Data.SqlClient.SqlDataReader”。我的sql查询的结果在哪里,为什么我不能检索它们?
我知道的ToString在做什么它是假设的话,我根本不知道该用什么。 .GetString和.GetValue都很完美。谢谢! – Brian 2012-04-27 16:25:13