1 窗口form中追加控件datagridview
2 窗口form程序中设定:
Public Class FormDummyman
'链接对象设定
Dim conn As String = "data source=服务器名称;database=数据库名称; user id=登录用户名;password=密码;"
'连接
Dim connection As New SqlClient.SqlConnection
'DB中指定表的内容
Dim dataSet As New DataSet
'DataTable
Dim table As New DataTable
'共通
Dim common As New Common
'画面启动
Public Sub FormDummyman_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'判断连接状态
If connection.State = ConnectionState.Closed Then
'连接数据库
connection.ConnectionString = conn
'数据库打开
connection.Open()
End If
2 窗口form程序中设定:
Public Class FormDummyman
'链接对象设定
Dim conn As String = "data source=服务器名称;database=数据库名称; user id=登录用户名;password=密码;"
'连接
Dim connection As New SqlClient.SqlConnection
'DB中指定表的内容
Dim dataSet As New DataSet
'DataTable
Dim table As New DataTable
'共通
Dim common As New Common
'画面启动
Public Sub FormDummyman_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'判断连接状态
If connection.State = ConnectionState.Closed Then
'连接数据库
connection.ConnectionString = conn
'数据库打开
connection.Open()
End If