首页 > 数据库技术 > 详细

VB.NET连接SQL_Server实例

时间:2019-01-20 21:56:26      阅读:299      评论:0      收藏:0      [点我收藏+]
Imports System.Data.SqlClient
Public Class Form1
    REM Public conn1 As SqlConnection = New SqlConnection("server=.; Integrated Security=False;Initial Catalog= mydatabase1; User ID= sa;password")
    Dim cn As SqlConnection
    Dim da As SqlDataAdapter
    Dim ds As DataSet
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim cnStr As String = "Data Source=(local);Initial Catalog=mydatabase1;Integrated Security=False;User ID=sa;Password=dhc3b@dhc;"
        cn = New SqlConnection(cnStr)
        da = New SqlDataAdapter("select * from mydatabase1.dbo.db_book", cn)
        ds = New DataSet()
        da.Fill(ds, "mydatabase1.dbo.db_book")
        DataGridView1.DataSource = ds.Tables("mydatabase1.dbo.db_book")
    End Sub
   
End Class

 

VB.NET连接SQL_Server实例

原文:https://www.cnblogs.com/yanweichen/p/10296260.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!