- Imports System.Data
- Imports System.Data.SqlClient REM 有数据库连接的时候就要写这两行
- Public Class Form1
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Using mycon As New SqlConnection("Data Source=lty-pc;Initial Catalog=Discuz!;Integrated Security=True")
- Dim sql As SqlCommand = New SqlCommand("select * from dnt_forums", mycon)
- mycon.Open()
- Dim Rs As SqlDataReader = sql.ExecuteReader
- If Rs.HasRows = True Then
- While Rs.Read
- Application.DoEvents()
- Label1.Text += Rs("fid").ToString() & vbCrLf
- End While
- End If
- Rs.Close()
- sql.Dispose()
- mycon.Close()
- End Using
- End Sub
- End Class
读出数据库中数据
最新推荐文章于 2021-12-26 20:41:56 发布