教你创建动态MSSQL数据库表


下面是利用SQL语句创建数据库、表、存储过程、视图、索引、规则、修改表、查看数据等的方法。所要增加的控件如下:

  以下是引用片段:


  Imports System.Data
  Imports System.Data.SqlClient
  Public Class Form1
  Inherits System.Windows.Forms.Form
  Private ConnectionString As String = "Data Source=.;Initial Catalog=;User Id=sa;Password=;"
  Private reader As SqlDataReader = Nothing
  Private conn As SqlConnection = Nothing
  Private cmd As SqlCommand = Nothing
  Private AlterTableBtn As System.Windows.Forms.Button
  Private sql As String = Nothing
  Private CreateOthersBtn As System.Windows.Forms.Button
  #Region " Windows 窗体设计器生成的代码 "
  '窗体重写处置以清理组件列表。
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  If disposing Then
  If Not (components Is Nothing) Then
  components.Dispose()
  End If
  End If
  MyBase.Dispose(disposing)
  End Sub
  Public Sub New()
  MyBase.New()
  InitializeComponent()
  End Sub
  Private components As System.ComponentModel.IContainer
  Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
  Friend WithEvents CreateDBBtn As System.Windows.Forms.Button
  Friend WithEvents CreateTableBtn As System.Windows.Forms.Button
  Friend WithEvents CreateSPBtn As System.Windows.Forms.Button
  Friend WithEvents CreateViewBtn As System.Windows.Forms.Button
  Friend WithEvents btnAlterTable As System.Windows.Forms.Button
  Friend WithEvents btnCreateOthers As System.Windows.Forms.Button
  Friend WithEvents btnDropTable As System.Windows.Forms.Button
  Friend WithEvents btnViewData As System.Windows.Forms.Button
  Friend WithEvents btnViewSP As System.Windows.Forms.Button
  Friend WithEvents btnViewView As System.Windows.Forms.Button
  Private Sub InitializeComponent()


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3