动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx

上传人:b****4 文档编号:6921148 上传时间:2023-05-07 格式:DOCX 页数:13 大小:16.81KB
下载 相关 举报
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第1页
第1页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第2页
第2页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第3页
第3页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第4页
第4页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第5页
第5页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第6页
第6页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第7页
第7页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第8页
第8页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第9页
第9页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第10页
第10页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第11页
第11页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第12页
第12页 / 共13页
动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx_第13页
第13页 / 共13页
亲,该文档总共13页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx

《动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx(13页珍藏版)》请在冰点文库上搜索。

动态创建SQL Server数据库表存储过程数据库教程 电脑资料Word格式文档下载.docx

ProtectedOverloadsOverridesSubDispose(ByValdisposingAsBoolean)

IfdisposingThen

IfNot(ponentsIsNothing)Then

ponents.Dispose()

EndIf

MyBase.Dispose(disposing)

EndSub

PublicSubNew()

MyBase.New()

InitializeComponent()

PrivateponentsAsSystem.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

Me.CreateViewBtn.Text="

创立视图"

btnAlterTable

Me.btnAlterTable.Location=NewSystem.Drawing.Point(441,9)

Me.btnAlterTable.Name="

btnAlterTable"

Me.btnAlterTable.TabIndex=4

Me.btnAlterTable.Text="

修改表"

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="

创立规那么和索引"

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)

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)

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)

#EndRegion

创立数据库

PrivateSubCreateDBBtnClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)

HandlesCreateDBBtn.Click

conn=NewSqlConnection(ConnectionString)

翻开连接

Ifconn.State<

>

ConnectionState.OpenThen

conn.Open()

MyDataBase为数据库名称

DimsqlAsString="

CREATEDATABASEMyDataBaseONPRIMARY(Name=MyDataBasedata,filename="

+

D:

\MyDataBase.mdf'

size=3,"

+"

maxsize=5,filegrowth=10%)logon"

(name=MyDataBaselog,"

filename='

\MyDataBase.ldf'

size=3,"

maxsize=20,filegrowth=1)"

cmd=NewSqlCommand(sql,conn)

Try

cmd.ExecuteNonQuery()

CatchaeAsSqlException

MessageBox.Show(ae.Message.ToString())

EndTry

创立表

PrivateSubCreateTableBtnClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)

HandlesCreateTableBtn.Click

Ifconn.State=ConnectionState.OpenThen

conn.Close()

ConnectionString="

InitialCatalog=MyDataBase;

conn.ConnectionString=ConnectionString

sql="

CREATETABLEmyTable"

(myIdINTEGERCONSTRAINTPKeyMyIdPRIMARYKEY,"

myNameCHAR(50)NOTNull,myAddressCHAR(255),myValuesFLOAT)"

添加纪录

INSERTINTOmyTable(myId,myName,myAddress,myValues)"

VALUES(1001,'

【孟宪会之精彩世界】之一'

'

xml.sz.luohuedu./'

100)"

VALUES(1002,'

【孟宪会之精彩世界】之二'

.erp800./lover/'

99)"

VALUES(1003,'

【孟宪会之精彩世界】之三'

VALUES(1004,'

【孟宪会之精彩世界】之四'

100)"

创立存储过程

PrivateSubCreateSPBtnClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)

HandlesCreateSPBtn.Click

CREATEPROCEDUREmyProcAS"

SELECTmyName,myAddressFROMmyTableGO"

ExecuteSQLStmt(sql)

创立视图

PrivateSubCreateViewBtnClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)

HandlesCreateViewBtn.Click

CREATEVIEWmyViewASSELECTmyNameFROMmyTable"

修改表

PrivateSubbtnAlterTableClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)

HandlesbtnAlterTable.Click

ALTERTABLEMyTableADDnewColdatetimeNOTNULLDEFAULT(getdate())"

创立规那么和索引

PrivateSubbtnCreateOthersClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)

HandlesbtnCreateOthers.Click

CREATEUNIQUEINDEX"

myIdxONmyTable(myName)"

CREATERULEmyRule"

AS@myValues>

=90AND@myValues<

9999"

删除表

PrivateSubbtnDropTableClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)

HandlesbtnDropTable.Click

DROPTABLEMyTable"

浏览表数据

PrivateSubbtnViewDataClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)

HandlesbtnViewData.Click

DimdaAsNewSqlDataAdapter("

SELECT*FROMmyTable"

conn)

DimdsAsNewDataSet("

myTable"

da.Fill(ds,"

DataGrid1.DataSource=ds.Tables("

).DefaultView

浏览存储过程

PrivateSubbtnViewSPClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)

HandlesbtnViewSP.Click

myProc"

SP"

DataGrid1.DataSource=ds.DefaultViewManager

浏览视图

PrivateSubbtnViewViewClick(ByValsenderAsSystem.Object,ByValeAsSystem.EventA

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > PPT模板 > 商务科技

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2