当我尝试执行此代码时,它会抛出一个错误,指出sql异常未处理。
Dim cmdString = "Select * from STUDENT"
connection = New SqlConnection("Data Source=gandharva.sdf")
Dim command As SqlCommand
command = New SqlCommand(cmdString, connection)
connection.Open()
Dim reader As SqlDataReader
reader = command.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read()
Console.WriteLine(reader("studentname").ToString())
End While
Console.WriteLine("Press ENTER to exit")
Console.ReadLine()
End Sub
任何帮助都将不胜感激。
答案 0 :(得分:0)
您必须引用SQL Server Compact,System.Data.SqlServerCe的ADO.NET提供程序,并使用SqlCeConnection,SqlCeDataReader,SqlCeCommand等。