導航:首頁 > 編程大全 > 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更新win11後老文件怎麼刪除 瀏覽:93
東莞哪裡好學編程 瀏覽:921
sst89e516rd單片機怎樣燒入程序 瀏覽:140
java既繼承又實現兩個介面 瀏覽:131
網路電視總是顯示錯誤碼 瀏覽:606
網路報刊有哪些雜志 瀏覽:718
dedecms網站安全 瀏覽:459
文件可以以什麼格式存資料庫 瀏覽:626
列印十幾張文件多少錢 瀏覽:818
smtp附件文件名太長 瀏覽:712
lnk文件mac用什麼打開 瀏覽:476
義烏編程哪裡學 瀏覽:754
win10啟動不了拷文件 瀏覽:167
git忽略文件生效 瀏覽:255
a4紙寫文件一般寫多少行 瀏覽:647
資料庫故障的分類有 瀏覽:945
怎麼在微信上賣化妝品的真的假的 瀏覽:894
軟考網路管理員真題下載 瀏覽:21
沒有許可權訪問文件夾 瀏覽:121
ps將文件的位深度 瀏覽:705

友情鏈接