導航:首頁 > 編程大全 > vbnet本地資料庫

vbnet本地資料庫

發布時間:2025-07-11 17:17:25

『壹』 vb.net和mysql本地資料庫連接

直接在代碼里連接就可以啦。
首先本地的資料庫要啟動起來。然後直接再點net里的配置文件里配置資料庫的訪問,然後就可以發文了資料庫的地址,用戶名和密碼

『貳』 求用vb.net寫一個讀取資料庫數據的簡單操作。

Option Explicit On
Option Strict On

Imports System
Imports System.Data
Imports System.Data.SqlClient

Public Class Program
Public Shared Sub Main()

Dim connectionString As String = _
"Data Source=(local);Initial Catalog=Northwind;" _
& "Integrated Security=true"

' Provide the query string with a parameter placeholder.
Dim queryString As String = _
"SELECT ProctID, UnitPrice, ProctName from dbo.Procts " _
& "WHERE UnitPrice > @pricePoint " _
& "ORDER BY UnitPrice DESC;"

' Specify the parameter value.
Dim paramValue As Integer = 5

' Create and open the connection in a using block. This
' ensures that all resources will be closed and disposed
' when the code exits.
Using connection As New SqlConnection(connectionString)

' Create the Command and Parameter objects.
Dim command As New SqlCommand(queryString, connection)
command.Parameters.AddWithValue("@pricePoint", paramValue)

' Open the connection in a try/catch block.
' Create and execute the DataReader, writing the result
' set to the console window.
Try
connection.Open()
Dim dataReader As SqlDataReader = _
command.ExecuteReader()
Do While dataReader.Read()
Console.WriteLine( _
vbTab & "{0}" & vbTab & "{1}" & vbTab & "{2}", _
dataReader(0), dataReader(1), dataReader(2))
Loop
dataReader.Close()

Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Console.ReadLine()
End Using
End Sub
End Class

這是我在vs2010中微軟自帶的MSDN示例代碼裡面拷的,是關於ADO.net連接sql的操作。
希望對你有幫助。 如果你還需要其他的,我也可以再拷給你看。

閱讀全文

與vbnet本地資料庫相關的資料

熱點內容
win10加密共享文件夾不見了 瀏覽:412
平板電腦無法打開文件 瀏覽:718
win10如何強制重命名文件 瀏覽:204
java集合隨機打亂順序 瀏覽:805
qq怎麼解綁app 瀏覽:995
蘋果設備優盤考文件 瀏覽:662
java項目部署與測試 瀏覽:728
個人微信號和公眾平台 瀏覽:988
微信顯示網路不可用 瀏覽:478
現實編程怎麼敲鍵盤 瀏覽:950
怎麼做招標文件 瀏覽:543
黑蘋果macminidiy 瀏覽:105
系統暫時刪除應用程序 瀏覽:400
怎麼更改qq郵箱的賬號和密碼 瀏覽:947
電視劇周邊是什麼網路用語 瀏覽:130
網路信號怎麼來的 瀏覽:802
win10文件默認顏色 瀏覽:713
安卓的榮耀戰區 瀏覽:621
使excel文件損壞的原因 瀏覽:746
有個搜題網站叫知什麼 瀏覽:17

友情鏈接