教你创建动态MQL 数据库表(6)_MySQL数据库_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

教你创建动态MQL 数据库表(6)

作者:黑客防线网安MYSQL维护基地 来源:黑客防线网安MYSQL维护基地 浏览次数:0

本篇关键词:数据库动态创建conn
黑客防线网安网讯: '浏览表数据   Private Sub btnViewData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _   Handles btnViewData.Click   conn = New SqlConnection(Con...
 '浏览表数据
  Private Sub btnViewData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  Handles btnViewData.Click
  conn = New SqlConnection(ConnectionString)
  If conn.State = ConnectionState.Open Then
  conn.Close()
  End If
  ConnectionString = "Data Source=.;Initial Catalog=MyDataBase;User Id=sa;Password=;"
  conn.ConnectionString = ConnectionString
  conn.Open()
  Dim da As New SqlDataAdapter("SELECT * FROM myTable", conn)
  Dim ds As New DataSet("myTable")
  da.Fill(ds, "myTable")
  DataGrid1.DataSource = ds.Tables("myTable").DefaultView
  End Sub
  '浏览存储过程
  Private Sub btnViewSP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  Handles btnViewSP.Click
  conn = New SqlConnection(ConnectionString)
  If conn.State = ConnectionState.Open Then
  conn.Close()
  End If
  ConnectionString = "Data Source=.;Initial Catalog=MyDataBase;User Id=sa;Password=;"
  conn.ConnectionString = ConnectionString
  conn.Open()
  Dim da As New SqlDataAdapter("myProc", conn)
  Dim ds As New DataSet("SP")
  da.Fill(ds, "SP")
  DataGrid1.DataSource = ds.DefaultViewManager
  End Sub
  '浏览视图
  Private Sub btnViewView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  Handles btnViewView.Click
  conn = New SqlConnection(ConnectionString)
  If conn.State = ConnectionState.Open Then
  conn.Close()
  End If
  ConnectionString = "Data Source=.;Initial Catalog=MyDataBase;User Id=sa;Password=;"
  conn.ConnectionString = ConnectionString
  conn.Open()
  Dim da As New SqlDataAdapter("SELECT * FROM myView", conn)
  Dim ds As New DataSet()
  da.Fill(ds)
  DataGrid1.DataSource = ds.DefaultViewManager
  End Sub
  Private Sub ExecuteSQLStmt(ByVal sql As String)
  conn = New SqlConnection(ConnectionString)
  ' 打开连接
  If conn.State = ConnectionState.Open Then
  conn.Close()
  End If
  ConnectionString = "Data Source=.;Initial Catalog=MyDataBase;User Id=sa;Password=;"
  conn.ConnectionString = ConnectionString
  conn.Open()
  cmd = New SqlCommand(sql, conn)
  Try
  cmd.ExecuteNonQuery()
  Catch ae As SqlException
  MessageBox.Show(ae.Message.ToString())
  End Try
  End Sub
  End Class
    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-8690-1.html
网站维护教程更新时间:2012-03-20 04:59:39  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer