将数据从数据库显示到VB.Net应用程序的最佳方式?
我现在正在制作贷款管理应用程序,我只想问一下在VB.Net中查看贷款数据的最佳方式是什么?顺便说一下,我正在使用MySQL作为数据库。我希望这里有一些东西可以帮助阅读SQL,它可能需要一些编辑和构建,但我仍然希望它能有所帮助将数据从数据库显示到VB.Net应用程序的最佳方式?,vb.net,Vb.net,我现在正在制作贷款管理应用程序,我只想问一下在VB.Net中查看贷款数据的最佳方式是什么?顺便说一下,我正在使用MySQL作为数据库。我希望这里有一些东西可以帮助阅读SQL,它可能需要一些编辑和构建,但我仍然希望它能有所帮助 Dim conString As String = "data source=ServerName;" & _ "initial catalog=DBName;" & _
Dim conString As String = "data source=ServerName;" & _
"initial catalog=DBName;" & _
"integrated security=SSPI;" & _
"persist security info=false;"
Dim conSQL As New SqlConnection(conString)
conSQL.Open()
Dim cmdSQL As New SqlCommand()
cmdSQL.CommandType = Data.CommandType.Text
cmdSQL.CommandText = "SELECT FieldName1, FieldName2 FROM MyTable"
Dim adptSQL As New SqlClient.SqlDataAdapter(cmdSQL)
Dim myDataSet As New DataSet()
adptSQL.Fill(myDataSet)
conSQL.Close()
With myDataSet.Tables(0)
For rowNumber As Integer = 0 To .Rows.Count - 1
With .Rows(rowNumber)
Console.WriteLine(String.Format("Field1: {0}, Field2: {1}", _
.Item(0).Value.ToString, _
.Item(1).Value.ToString))
End With
Next
End With
我认为这取决于您,您可以添加一个网格并将其绑定到数据库,这样您就可以可视化您的数据