学生选修管理系统(vb+sql源代码)
发布网友
发布时间:2022-05-11 23:10
我来回答
共1个回答
热心网友
时间:2023-10-24 16:20
Imports System.Data.SqlClient
Mole database
Public values As Integer
Public sql_conn As SqlConnection
Dim sql_comm As SqlCommand
Dim sql_dataadapter As SqlDataAdapter
Public mytable As DataTable
Dim conn_str As String
Dim sql_str As String Public Sub sql_exectute(ByVal sql_str As String)
conn_str = "Data Source=127.0.0.1;Initial Catalog=select_datebase;User ID=sa"
Try
sql_conn = New SqlConnection
sql_conn.ConnectionString = conn_str
sql_conn.Open() sql_comm = New SqlCommand
sql_comm.Connection = sql_conn
sql_comm.CommandType = CommandType.Text
sql_comm.CommandText = sql_str sql_dataadapter = New SqlDataAdapter
mytable = New DataTable
sql_dataadapter.SelectCommand = sql_comm
sql_dataadapter.Fill(mytable)
Catch ex As Exception
MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try sql_conn.Close()
End Sub
End Mole 这是连接sql数据库