'连接数据库的方法:
Public Shared Function getConnectionString() As String
Dim conStr As String = System.Configuration.ConfigurationManager.ConnectionStrings("TEST.ConnectionString").ConnectionString
Return conStr
End Function
'查询某个表
Public Shared Function getFileCount() As Boolean
Using connection1 As New System.Data.SqlClient.SqlConnection(getConnectionString())
Dim sqlCommand1 As New System.Data.SqlClient.SqlCommand
Dim reader1 As System.Data.SqlClient.SqlDataReader
connection1.Open()
sqlCommand1 = New System.Data.SqlClient.SqlCommand("select * From TableName , connection1)
s

这篇博客介绍了如何在VB.NET中使用SqlCommand类来连接和操作数据库,包括获取连接字符串、查询表数据以及调用存储过程的方法。示例代码展示了打开数据库连接、执行SQL查询和参数化存储过程的步骤。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



