成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

怎么創(chuàng)建動(dòng)態(tài)MSSQL數(shù)據(jù)庫表-創(chuàng)新互聯(lián)

這篇文章主要講解了“怎么創(chuàng)建動(dòng)態(tài)MSSQL數(shù)據(jù)庫表”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么創(chuàng)建動(dòng)態(tài)MSSQL數(shù)據(jù)庫表”吧!

目前成都創(chuàng)新互聯(lián)已為1000+的企業(yè)提供了網(wǎng)站建設(shè)、域名、雅安服務(wù)器托管綿陽服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計(jì)、柳城網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

復(fù)制代碼 代碼如下:   

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窗體設(shè)計(jì)器生成的代碼"   '窗體重寫處置以清理組件列表。   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()

復(fù)制代碼 代碼如下:

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="創(chuàng)建數(shù)據(jù)庫"   '   'CreateTableBtn   '   Me.CreateTableBtn.Location=NewSystem.Drawing.Point(139,9)   Me.CreateTableBtn.Name="CreateTableBtn"   Me.CreateTableBtn.TabIndex=1   Me.CreateTableBtn.Text="創(chuàng)建表"   '   '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="創(chuàng)建存儲(chǔ)過程"   '   'CreateViewBtn   '   Me.CreateViewBtn.Location=NewSystem.Drawing.Point(350,9)   Me.CreateViewBtn.Name="CreateViewBtn"   Me.CreateViewBtn.TabIndex=3中國(guó)網(wǎng)管聯(lián)盟www.bitscn.com   Me.CreateViewBtn.Text="創(chuàng)建視圖"   '   'btnAlterTable   '   Me.btnAlterTable.Location=NewSystem.Drawing.Point(441,9)   Me.btnAlterTable.Name="btnAlterTable"   Me.btnAlterTable.TabIndex=4   Me.btnAlterTable.Text="修改表"
#p#

復(fù)制代碼 代碼如下:   

'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="創(chuàng)建規(guī)則和索引"   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="查看數(shù)據(jù)"   '   '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="查看存儲(chǔ)過程"   '   '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,_

 復(fù)制代碼 代碼如下:   

Me.CreateViewBtn,Me.CreateSPBtn,Me.CreateTableBtn,Me.CreateDBBtn})   Me.Name="Form1"   Me.Text="動(dòng)態(tài)創(chuàng)建SQLServer數(shù)據(jù)庫、表、存儲(chǔ)過程等架構(gòu)信息"   CType(Me.DataGrid1,System.ComponentModel.ISupportInitialize).EndInit()   Me.ResumeLayout(False)   EndSub   #EndRegion   '創(chuàng)建數(shù)據(jù)庫   PrivateSubCreateDBBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_   HandlesCreateDBBtn.Click   conn=NewSqlConnection(ConnectionString)   '打開連接   Ifconn.State<>ConnectionState.OpenThen   conn.Open()   EndIf   'MyDataBase為數(shù)據(jù)庫名稱   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   '創(chuàng)建表   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()   '添加紀(jì)錄   54com.cn   sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_   "VALUES(1001,_'【孟憲會(huì)之精彩世界】之一','http://xml.sz.luohuedu.net/',100)"   cmd=NewSqlCommand(sql,conn)   cmd.ExecuteNonQuery()   sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_   "VALUES(1002,'【孟憲會(huì)之精彩世界】之二','http://www.erp800.com/net_lover/',99)"
#p#

復(fù)制代碼 代碼如下:   

cmd=NewSqlCommand(sql,conn)   cmd.ExecuteNonQuery()   sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_   "VALUES(1003,'【孟憲會(huì)之精彩世界】之三','http://xml.sz.luohuedu.net/',99)"   cmd=NewSqlCommand(sql,conn)   cmd.ExecuteNonQuery()   sql="INSERTINTOmyTable(myId,myName,myAddress,myValues)"+_   "VALUES(1004,'【孟憲會(huì)之精彩世界】之四','http://www.erp800.com/net_lover/',100)"   cmd=NewSqlCommand(sql,conn)   cmd.ExecuteNonQuery()   CatchaeAsSqlException   MessageBox.Show(ae.Message.ToString())   EndTry   EndSub   '創(chuàng)建存儲(chǔ)過程   PrivateSubCreateSPBtn_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)_   HandlesCreateSPBtn.Click   sql="CREATEPROCEDUREmyProcAS"+"SELECTmyName,myAddressFROMmyTableGO"   ExecuteSQLStmt(sql)   EndSub   '創(chuàng)建視圖   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   '創(chuàng)建規(guī)則和索引   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 
復(fù)制代碼
 代碼如下:
  '瀏覽表數(shù)據(jù)   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   '瀏覽存儲(chǔ)過程   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

感謝各位的閱讀,以上就是“怎么創(chuàng)建動(dòng)態(tài)MSSQL數(shù)據(jù)庫表”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)怎么創(chuàng)建動(dòng)態(tài)MSSQL數(shù)據(jù)庫表這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

當(dāng)前標(biāo)題:怎么創(chuàng)建動(dòng)態(tài)MSSQL數(shù)據(jù)庫表-創(chuàng)新互聯(lián)
標(biāo)題來源:http://jinyejixie.com/article0/csdsio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)、響應(yīng)式網(wǎng)站、自適應(yīng)網(wǎng)站、服務(wù)器托管、建站公司外貿(mào)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化
乌兰浩特市| 彭阳县| 通州市| 庆阳市| 民丰县| 双峰县| 德钦县| 灵武市| 香港| 洛浦县| 临城县| 连江县| 阜阳市| 武夷山市| 磐安县| 香河县| 汝阳县| 榆树市| 怀柔区| 措勤县| 石狮市| 紫阳县| 偃师市| 马尔康县| 沂南县| 绵阳市| 内丘县| 宁安市| 崇义县| 华亭县| 达尔| 高阳县| 辉南县| 清远市| 贺州市| 永胜县| 华池县| 宁武县| 广西| 南开区| 湘西|