为什么感觉最后一段不太完整呢
DataGridView1是什么时候定义出来的?
Imports MySql.Data.MySqlClient
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TextBox1.Text = 1
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Dim constr As String = "server=localhost;userid=root ;password=123456 ;database=test;pooling=false"
' 测试连接
' Dim myConn As MySqlConnection = New MySqlConnection(constr)
'Try
' myConn.Open()
'MsgBox("数据库连接成功!")
' Catch ex As Exception
'MsgBox("数据库连接失败!" & ex.Message & vbCrLf)
' Finally
' myConn.Close()
' End Try
Dim con As String
Dim i As Integer
i = TextBox1.Text
Dim mysql As MySqlConnection
Dim query As String = "select * from cms_detail where id=" & i
con = "server=localhost;userid=root ;password=123456 ;database=test;pooling=false"
mysql = New MySqlConnection(con)
'创建一个适配器
Dim adapter As MySqlDataAdapter = New MySqlDataAdapter(query, con)
'创建一个datable,用适配器来填充datatable
Dim tab As DataTable = New DataTable()
adapter.Fill(tab)
DataGridView1.DataSource = tab
'conn.Close()
End Sub
End Class {:1_908:}完全看不懂 看起来太高深了,直接蒙圈, 感谢分享 膜拜大神,不会编程,看不懂~~~~~ 支持
感谢分享 不错不错支持一下 膜拜大神,虽然懂点VB,但是完全看不懂。
页:
[1]
2