DDR爱好者之家 Design By 杰米
以下是引用片段:
复制代码 代码如下:
ImportsSystem.Data
ImportsSystem.Data.SqlClient
PublicClassForm1
InheritsSystem.Windows.Forms.Form
PrivateConnectionStringAsString="DataSource=.;InitialCatalog=;UserId=sa;Password=;"
PrivatereaderAsSqlDataReader=Nothing
PrivateconnAsSqlConnection=Nothing
PrivatecmdAsSqlCommand=Nothing
PrivateAlterTableBtnAsSystem.Windows.Forms.Button
PrivatesqlAsString=Nothing
PrivateCreateOthersBtnAsSystem.Windows.Forms.Button
#Region"Windows窗体设计器生成的代码"
'窗体重写处置以清理组件列表。
ProtectedOverloadsOverridesSubDispose(ByValdisposingAsBoolean)
IfdisposingThen
IfNot(componentsIsNothing)Then
components.Dispose()
EndIf
EndIf
MyBase.Dispose(disposing)
EndSub
PublicSubNew()
MyBase.New()
InitializeComponent()
EndSub
PrivatecomponentsAsSystem.ComponentModel.IContainer
FriendWithEventsDataGrid1AsSystem.Windows.Forms.DataGrid
FriendWithEventsCreateDBBtnAsSystem.Windows.Forms.Button
FriendWithEventsCreateTableBtnAsSystem.Windows.Forms.Button
FriendWithEventsCreateSPBtnAsSystem.Windows.Forms.Button
FriendWithEventsCreateViewBtnAsSystem.Windows.Forms.Button
FriendWithEventsbtnAlterTableAsSystem.Windows.Forms.Button
FriendWithEventsbtnCreateOthersAsSystem.Windows.Forms.Button
FriendWithEventsbtnDropTableAsSystem.Windows.Forms.Button
FriendWithEventsbtnViewDataAsSystem.Windows.Forms.Button
FriendWithEventsbtnViewSPAsSystem.Windows.Forms.Button
FriendWithEventsbtnViewViewAsSystem.Windows.Forms.Button
PrivateSubInitializeComponent()
复制代码 代码如下:
Me.CreateDBBtn=NewSystem.Windows.Forms.Button()
Me.CreateTableBtn=NewSystem.Windows.Forms.Button()
Me.CreateSPBtn=NewSystem.Windows.Forms.Button()
Me.CreateViewBtn=NewSystem.Windows.Forms.Button()
Me.btnAlterTable=NewSystem.Windows.Forms.Button()
Me.btnCreateOthers=NewSystem.Windows.Forms.Button()
Me.btnDropTable=NewSystem.Windows.Forms.Button()
Me.btnViewData=NewSystem.Windows.Forms.Button()
Me.btnViewSP=NewSystem.Windows.Forms.Button()
Me.btnViewView=NewSystem.Windows.Forms.Button()
Me.DataGrid1=NewSystem.Windows.Forms.DataGrid()
CType(Me.DataGrid1,System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'CreateDBBtn
'
Me.CreateDBBtn.Location=NewSystem.Drawing.Point(19,9)
Me.CreateDBBtn.Name="CreateDBBtn"
Me.CreateDBBtn.Size=NewSystem.Drawing.Size(104,23)
Me.CreateDBBtn.TabIndex=0
Me.CreateDBBtn.Text="创建数据库"
'
'CreateTableBtn
'
Me.CreateTableBtn.Location=NewSystem.Drawing.Point(139,9)
Me.CreateTableBtn.Name="CreateTableBtn"
Me.CreateTableBtn.TabIndex=1
Me.CreateTableBtn.Text="创建表"
'
'CreateSPBtn
'
Me.CreateSPBtn.Location=NewSystem.Drawing.Point(230,9)
Me.CreateSPBtn.Name="CreateSPBtn"
Me.CreateSPBtn.Size=NewSystem.Drawing.Size(104,23)
Me.CreateSPBtn.TabIndex=2
Me.CreateSPBtn.Text="创建存储过程"
'
'CreateViewBtn
'
Me.CreateViewBtn.Location=NewSystem.Drawing.Point(350,9)
Me.CreateViewBtn.Name="CreateViewBtn"
Me.CreateViewBtn.TabIndex=3中国网管联盟www.bitscn.com
Me.CreateViewBtn.Text="创建视图"
'
'btnAlterTable
'
Me.btnAlterTable.Location=NewSystem.Drawing.Point(441,9)
Me.btnAlterTable.Name="btnAlterTable"
Me.btnAlterTable.TabIndex=4
Me.btnAlterTable.Text="修改表"
#p#
复制代码 代码如下:
'btnCreateOthers
'
Me.btnCreateOthers.Location=NewSystem.Drawing.Point(17,43)
Me.btnCreateOthers.Name="btnCreateOthers"
Me.btnCreateOthers.Size=NewSystem.Drawing.Size(104,23)
Me.btnCreateOthers.TabIndex=5
Me.btnCreateOthers.Text="创建规则和索引"
feedom.net
'
'btnDropTable
'
Me.btnDropTable.Location=NewSystem.Drawing.Point(138,43)
Me.btnDropTable.Name="btnDropTable"
Me.btnDropTable.TabIndex=6
Me.btnDropTable.Text="删除表"
'
'btnViewData
'
Me.btnViewData.Location=NewSystem.Drawing.Point(351,43)
Me.btnViewData.Name="btnViewData"
Me.btnViewData.TabIndex=7
Me.btnViewData.Text="查看数据"
'
'btnViewSP
'
Me.btnViewSP.Location=NewSystem.Drawing.Point(230,43)
feedom.net
Me.btnViewSP.Name="btnViewSP"
Me.btnViewSP.Size=NewSystem.Drawing.Size(104,23)
Me.btnViewSP.TabIndex=8
Me.btnViewSP.Text="查看存储过程"
'
'btnViewView
'
Me.btnViewView.Location=NewSystem.Drawing.Point(443,43)
Me.btnViewView.Name="btnViewView"
Me.btnViewView.TabIndex=9
Me.btnViewView.Text="查看视图"
'
'DataGrid1
'
Me.DataGrid1.DataMember=""
Me.DataGrid1.HeaderForeColor=System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location=NewSystem.Drawing.Point(20,76)54com.cn
Me.DataGrid1.Name="DataGrid1"
Me.DataGrid1.Size=NewSystem.Drawing.Size(500,183)
Me.DataGrid1.TabIndex=10
'
'Form1
'
Me.AutoScaleBaseSize=NewSystem.Drawing.Size(5,13)
Me.ClientSize=NewSystem.Drawing.Size(538,281)
Me.Controls.AddRange(NewSystem.Windows.Forms.Control(){Me.DataGrid1,Me.btnViewView,_
Me.btnViewSP,Me.btnViewData,Me.btnDropTable,Me.btnCreateOthers,Me.btnAlterTable,_
复制代码 代码如下:
Me.CreateViewBtn,Me.CreateSPBtn,Me.CreateTableBtn,Me.CreateDBBtn})
Me.Name="Form1"
Me.Text="动态创建SQLServer数据库、表、存储过程等架构信息"
CType(Me.DataGrid1,System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
EndSub
#EndRegion
'创建数据库
PrivateSubCreateDBBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesCreateDBBtn.Click
conn=NewSqlConnection(ConnectionString)
'打开连接
Ifconn.State<>ConnectionState.OpenThen
conn.Open()
EndIf
'MyDataBase为数据库名称
DimsqlAsString="CREATEDATABASEMyDataBaseONPRIMARY(Name=MyDataBase_data,filename="+_
54com.cn
"'D:\MyDataBase.mdf',size=3,"+"maxsize=5,filegrowth=10%)logon"+"(name=MyDataBase_log,"+_
"filename='D:\MyDataBase.ldf',size=3,"+"maxsize=20,filegrowth=1)"
cmd=NewSqlCommand(sql,conn)
Try
cmd.ExecuteNonQuery()
CatchaeAsSqlException
MessageBox.Show(ae.Message.ToString())
EndTry
EndSub
'创建表
PrivateSubCreateTableBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesCreateTableBtn.Click
conn=NewSqlConnection(ConnectionString)
'打开连接
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
sql="CREATETABLEmyTable"+"(myIdINTEGERCONSTRAINTPKeyMyIdPRIMARYKEY,"+_
"myNameCHAR(50)NOTNull,myAddressCHAR(255),myValuesFLOAT)"
cmd=NewSqlCommand(sql,conn)
Try
cmd.ExecuteNonQuery()
'添加纪录
54com.cn
sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_
"VALUES(1001,_'【孟宪会之精彩世界】之一','http://xml.sz.luohuedu.net/',100)"
cmd=NewSqlCommand(sql,conn)
cmd.ExecuteNonQuery()
sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_
"VALUES(1002,'【孟宪会之精彩世界】之二','http://www.erp800.com/net_lover/',99)"
#p#
复制代码 代码如下:
cmd=NewSqlCommand(sql,conn)
cmd.ExecuteNonQuery()
sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_
"VALUES(1003,'【孟宪会之精彩世界】之三','http://xml.sz.luohuedu.net/',99)"
cmd=NewSqlCommand(sql,conn)
cmd.ExecuteNonQuery()
sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_
"VALUES(1004,'【孟宪会之精彩世界】之四','http://www.erp800.com/net_lover/',100)"
cmd=NewSqlCommand(sql,conn)
cmd.ExecuteNonQuery()
CatchaeAsSqlException
MessageBox.Show(ae.Message.ToString())
EndTry
EndSub
'创建存储过程
PrivateSubCreateSPBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesCreateSPBtn.Click
sql="CREATEPROCEDUREmyProcAS"+"SELECTmyName,myAddressFROMmyTableGO"
ExecuteSQLStmt(sql)
EndSub
'创建视图
PrivateSubCreateViewBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesCreateViewBtn.Click
sql="CREATEVIEWmyViewASSELECTmyNameFROMmyTable"
ExecuteSQLStmt(sql)
EndSub
'修改表
PrivateSubbtnAlterTable_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
54com.cn
HandlesbtnAlterTable.Click
sql="ALTERTABLEMyTableADDnewColdatetimeNOTNULLDEFAULT(getdate())"
ExecuteSQLStmt(sql)
EndSub
'创建规则和索引
PrivateSubbtnCreateOthers_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnCreateOthers.Click
sql="CREATEUNIQUEINDEX"+"myIdxONmyTable(myName)"
ExecuteSQLStmt(sql)
sql="CREATERULEmyRule"+"AS@myValues>=90AND@myValues<9999"
ExecuteSQLStmt(sql)
EndSub
'删除表
PrivateSubbtnDropTable_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnDropTable.Click
DimsqlAsString="DROPTABLEMyTable"
ExecuteSQLStmt(sql)
EndSub
复制代码 代码如下:
'浏览表数据
PrivateSubbtnViewData_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnViewData.Click
conn=NewSqlConnection(ConnectionString)
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
DimdaAsNewSqlDataAdapter("SELECT*FROMmyTable",conn)
DimdsAsNewDataSet("myTable")
da.Fill(ds,"myTable")
DataGrid1.DataSource=ds.Tables("myTable").DefaultView
EndSub
'浏览存储过程
PrivateSubbtnViewSP_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnViewSP.Click
conn=NewSqlConnection(ConnectionString)
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
DimdaAsNewSqlDataAdapter("myProc",conn)
DimdsAsNewDataSet("SP")
da.Fill(ds,"SP")
DataGrid1.DataSource=ds.DefaultViewManager
EndSub
'浏览视图
PrivateSubbtnViewView_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnViewView.Click
conn=NewSqlConnection(ConnectionString)
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
DimdaAsNewSqlDataAdapter("SELECT*FROMmyView",conn)
DimdsAsNewDataSet()
da.Fill(ds)
DataGrid1.DataSource=ds.DefaultViewManager
EndSub
PrivateSubExecuteSQLStmt(ByValsqlAsString)
conn=NewSqlConnection(ConnectionString)
'打开连接
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
cmd=NewSqlCommand(sql,conn)
Try
cmd.ExecuteNonQuery()
CatchaeAsSqlException
MessageBox.Show(ae.Message.ToString())
EndTry
EndSub
EndClass
复制代码 代码如下:
ImportsSystem.Data
ImportsSystem.Data.SqlClient
PublicClassForm1
InheritsSystem.Windows.Forms.Form
PrivateConnectionStringAsString="DataSource=.;InitialCatalog=;UserId=sa;Password=;"
PrivatereaderAsSqlDataReader=Nothing
PrivateconnAsSqlConnection=Nothing
PrivatecmdAsSqlCommand=Nothing
PrivateAlterTableBtnAsSystem.Windows.Forms.Button
PrivatesqlAsString=Nothing
PrivateCreateOthersBtnAsSystem.Windows.Forms.Button
#Region"Windows窗体设计器生成的代码"
'窗体重写处置以清理组件列表。
ProtectedOverloadsOverridesSubDispose(ByValdisposingAsBoolean)
IfdisposingThen
IfNot(componentsIsNothing)Then
components.Dispose()
EndIf
EndIf
MyBase.Dispose(disposing)
EndSub
PublicSubNew()
MyBase.New()
InitializeComponent()
EndSub
PrivatecomponentsAsSystem.ComponentModel.IContainer
FriendWithEventsDataGrid1AsSystem.Windows.Forms.DataGrid
FriendWithEventsCreateDBBtnAsSystem.Windows.Forms.Button
FriendWithEventsCreateTableBtnAsSystem.Windows.Forms.Button
FriendWithEventsCreateSPBtnAsSystem.Windows.Forms.Button
FriendWithEventsCreateViewBtnAsSystem.Windows.Forms.Button
FriendWithEventsbtnAlterTableAsSystem.Windows.Forms.Button
FriendWithEventsbtnCreateOthersAsSystem.Windows.Forms.Button
FriendWithEventsbtnDropTableAsSystem.Windows.Forms.Button
FriendWithEventsbtnViewDataAsSystem.Windows.Forms.Button
FriendWithEventsbtnViewSPAsSystem.Windows.Forms.Button
FriendWithEventsbtnViewViewAsSystem.Windows.Forms.Button
PrivateSubInitializeComponent()
复制代码 代码如下:
Me.CreateDBBtn=NewSystem.Windows.Forms.Button()
Me.CreateTableBtn=NewSystem.Windows.Forms.Button()
Me.CreateSPBtn=NewSystem.Windows.Forms.Button()
Me.CreateViewBtn=NewSystem.Windows.Forms.Button()
Me.btnAlterTable=NewSystem.Windows.Forms.Button()
Me.btnCreateOthers=NewSystem.Windows.Forms.Button()
Me.btnDropTable=NewSystem.Windows.Forms.Button()
Me.btnViewData=NewSystem.Windows.Forms.Button()
Me.btnViewSP=NewSystem.Windows.Forms.Button()
Me.btnViewView=NewSystem.Windows.Forms.Button()
Me.DataGrid1=NewSystem.Windows.Forms.DataGrid()
CType(Me.DataGrid1,System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'CreateDBBtn
'
Me.CreateDBBtn.Location=NewSystem.Drawing.Point(19,9)
Me.CreateDBBtn.Name="CreateDBBtn"
Me.CreateDBBtn.Size=NewSystem.Drawing.Size(104,23)
Me.CreateDBBtn.TabIndex=0
Me.CreateDBBtn.Text="创建数据库"
'
'CreateTableBtn
'
Me.CreateTableBtn.Location=NewSystem.Drawing.Point(139,9)
Me.CreateTableBtn.Name="CreateTableBtn"
Me.CreateTableBtn.TabIndex=1
Me.CreateTableBtn.Text="创建表"
'
'CreateSPBtn
'
Me.CreateSPBtn.Location=NewSystem.Drawing.Point(230,9)
Me.CreateSPBtn.Name="CreateSPBtn"
Me.CreateSPBtn.Size=NewSystem.Drawing.Size(104,23)
Me.CreateSPBtn.TabIndex=2
Me.CreateSPBtn.Text="创建存储过程"
'
'CreateViewBtn
'
Me.CreateViewBtn.Location=NewSystem.Drawing.Point(350,9)
Me.CreateViewBtn.Name="CreateViewBtn"
Me.CreateViewBtn.TabIndex=3中国网管联盟www.bitscn.com
Me.CreateViewBtn.Text="创建视图"
'
'btnAlterTable
'
Me.btnAlterTable.Location=NewSystem.Drawing.Point(441,9)
Me.btnAlterTable.Name="btnAlterTable"
Me.btnAlterTable.TabIndex=4
Me.btnAlterTable.Text="修改表"
#p#
复制代码 代码如下:
'btnCreateOthers
'
Me.btnCreateOthers.Location=NewSystem.Drawing.Point(17,43)
Me.btnCreateOthers.Name="btnCreateOthers"
Me.btnCreateOthers.Size=NewSystem.Drawing.Size(104,23)
Me.btnCreateOthers.TabIndex=5
Me.btnCreateOthers.Text="创建规则和索引"
feedom.net
'
'btnDropTable
'
Me.btnDropTable.Location=NewSystem.Drawing.Point(138,43)
Me.btnDropTable.Name="btnDropTable"
Me.btnDropTable.TabIndex=6
Me.btnDropTable.Text="删除表"
'
'btnViewData
'
Me.btnViewData.Location=NewSystem.Drawing.Point(351,43)
Me.btnViewData.Name="btnViewData"
Me.btnViewData.TabIndex=7
Me.btnViewData.Text="查看数据"
'
'btnViewSP
'
Me.btnViewSP.Location=NewSystem.Drawing.Point(230,43)
feedom.net
Me.btnViewSP.Name="btnViewSP"
Me.btnViewSP.Size=NewSystem.Drawing.Size(104,23)
Me.btnViewSP.TabIndex=8
Me.btnViewSP.Text="查看存储过程"
'
'btnViewView
'
Me.btnViewView.Location=NewSystem.Drawing.Point(443,43)
Me.btnViewView.Name="btnViewView"
Me.btnViewView.TabIndex=9
Me.btnViewView.Text="查看视图"
'
'DataGrid1
'
Me.DataGrid1.DataMember=""
Me.DataGrid1.HeaderForeColor=System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location=NewSystem.Drawing.Point(20,76)54com.cn
Me.DataGrid1.Name="DataGrid1"
Me.DataGrid1.Size=NewSystem.Drawing.Size(500,183)
Me.DataGrid1.TabIndex=10
'
'Form1
'
Me.AutoScaleBaseSize=NewSystem.Drawing.Size(5,13)
Me.ClientSize=NewSystem.Drawing.Size(538,281)
Me.Controls.AddRange(NewSystem.Windows.Forms.Control(){Me.DataGrid1,Me.btnViewView,_
Me.btnViewSP,Me.btnViewData,Me.btnDropTable,Me.btnCreateOthers,Me.btnAlterTable,_
复制代码 代码如下:
Me.CreateViewBtn,Me.CreateSPBtn,Me.CreateTableBtn,Me.CreateDBBtn})
Me.Name="Form1"
Me.Text="动态创建SQLServer数据库、表、存储过程等架构信息"
CType(Me.DataGrid1,System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
EndSub
#EndRegion
'创建数据库
PrivateSubCreateDBBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesCreateDBBtn.Click
conn=NewSqlConnection(ConnectionString)
'打开连接
Ifconn.State<>ConnectionState.OpenThen
conn.Open()
EndIf
'MyDataBase为数据库名称
DimsqlAsString="CREATEDATABASEMyDataBaseONPRIMARY(Name=MyDataBase_data,filename="+_
54com.cn
"'D:\MyDataBase.mdf',size=3,"+"maxsize=5,filegrowth=10%)logon"+"(name=MyDataBase_log,"+_
"filename='D:\MyDataBase.ldf',size=3,"+"maxsize=20,filegrowth=1)"
cmd=NewSqlCommand(sql,conn)
Try
cmd.ExecuteNonQuery()
CatchaeAsSqlException
MessageBox.Show(ae.Message.ToString())
EndTry
EndSub
'创建表
PrivateSubCreateTableBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesCreateTableBtn.Click
conn=NewSqlConnection(ConnectionString)
'打开连接
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
sql="CREATETABLEmyTable"+"(myIdINTEGERCONSTRAINTPKeyMyIdPRIMARYKEY,"+_
"myNameCHAR(50)NOTNull,myAddressCHAR(255),myValuesFLOAT)"
cmd=NewSqlCommand(sql,conn)
Try
cmd.ExecuteNonQuery()
'添加纪录
54com.cn
sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_
"VALUES(1001,_'【孟宪会之精彩世界】之一','http://xml.sz.luohuedu.net/',100)"
cmd=NewSqlCommand(sql,conn)
cmd.ExecuteNonQuery()
sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_
"VALUES(1002,'【孟宪会之精彩世界】之二','http://www.erp800.com/net_lover/',99)"
#p#
复制代码 代码如下:
cmd=NewSqlCommand(sql,conn)
cmd.ExecuteNonQuery()
sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_
"VALUES(1003,'【孟宪会之精彩世界】之三','http://xml.sz.luohuedu.net/',99)"
cmd=NewSqlCommand(sql,conn)
cmd.ExecuteNonQuery()
sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_
"VALUES(1004,'【孟宪会之精彩世界】之四','http://www.erp800.com/net_lover/',100)"
cmd=NewSqlCommand(sql,conn)
cmd.ExecuteNonQuery()
CatchaeAsSqlException
MessageBox.Show(ae.Message.ToString())
EndTry
EndSub
'创建存储过程
PrivateSubCreateSPBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesCreateSPBtn.Click
sql="CREATEPROCEDUREmyProcAS"+"SELECTmyName,myAddressFROMmyTableGO"
ExecuteSQLStmt(sql)
EndSub
'创建视图
PrivateSubCreateViewBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesCreateViewBtn.Click
sql="CREATEVIEWmyViewASSELECTmyNameFROMmyTable"
ExecuteSQLStmt(sql)
EndSub
'修改表
PrivateSubbtnAlterTable_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
54com.cn
HandlesbtnAlterTable.Click
sql="ALTERTABLEMyTableADDnewColdatetimeNOTNULLDEFAULT(getdate())"
ExecuteSQLStmt(sql)
EndSub
'创建规则和索引
PrivateSubbtnCreateOthers_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnCreateOthers.Click
sql="CREATEUNIQUEINDEX"+"myIdxONmyTable(myName)"
ExecuteSQLStmt(sql)
sql="CREATERULEmyRule"+"AS@myValues>=90AND@myValues<9999"
ExecuteSQLStmt(sql)
EndSub
'删除表
PrivateSubbtnDropTable_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnDropTable.Click
DimsqlAsString="DROPTABLEMyTable"
ExecuteSQLStmt(sql)
EndSub
复制代码 代码如下:
'浏览表数据
PrivateSubbtnViewData_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnViewData.Click
conn=NewSqlConnection(ConnectionString)
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
DimdaAsNewSqlDataAdapter("SELECT*FROMmyTable",conn)
DimdsAsNewDataSet("myTable")
da.Fill(ds,"myTable")
DataGrid1.DataSource=ds.Tables("myTable").DefaultView
EndSub
'浏览存储过程
PrivateSubbtnViewSP_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnViewSP.Click
conn=NewSqlConnection(ConnectionString)
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
DimdaAsNewSqlDataAdapter("myProc",conn)
DimdsAsNewDataSet("SP")
da.Fill(ds,"SP")
DataGrid1.DataSource=ds.DefaultViewManager
EndSub
'浏览视图
PrivateSubbtnViewView_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_
HandlesbtnViewView.Click
conn=NewSqlConnection(ConnectionString)
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
DimdaAsNewSqlDataAdapter("SELECT*FROMmyView",conn)
DimdsAsNewDataSet()
da.Fill(ds)
DataGrid1.DataSource=ds.DefaultViewManager
EndSub
PrivateSubExecuteSQLStmt(ByValsqlAsString)
conn=NewSqlConnection(ConnectionString)
'打开连接
Ifconn.State=ConnectionState.OpenThen
conn.Close()
EndIf
ConnectionString="DataSource=.;InitialCatalog=MyDataBase;UserId=sa;Password=;"
conn.ConnectionString=ConnectionString
conn.Open()
cmd=NewSqlCommand(sql,conn)
Try
cmd.ExecuteNonQuery()
CatchaeAsSqlException
MessageBox.Show(ae.Message.ToString())
EndTry
EndSub
EndClass
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
2024年11月24日
2024年11月24日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]