导航:首页 > 编程大全 > 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本地数据库相关的资料

热点内容
编程的无效关键字有哪些 浏览:322
网络公司软文 浏览:303
怎么查看别人qq相册密码是什么软件 浏览:602
pdf怎么放文件 浏览:946
苹果无鼠标怎么复制文件 浏览:820
三国杀java安卓 浏览:299
百度体育app 浏览:113
如何比对两个excel表格数据是否一致 浏览:243
钉钉我的工作文件在哪里 浏览:815
u盘插入压缩文件夹不显示 浏览:463
extjsgrid列颜色 浏览:332
公司用特快ems寄的文件是什么 浏览:448
winform网络客户端 浏览:275
虚拟网络包括哪些 浏览:215
斗龙战士第四季升级版 浏览:56
手机文件管理里其他是什么垃圾 浏览:292
群文件怎么找回 浏览:497
win10更新win11后老文件怎么删除 浏览:93
东莞哪里好学编程 浏览:921
sst89e516rd单片机怎样烧入程序 浏览:140

友情链接