分類: 電腦/網(wǎng)絡(luò) 程序設(shè)計 其他編程語言

創(chuàng)新互聯(lián)主要從事做網(wǎng)站、成都網(wǎng)站制作、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)天峻,十載網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108
問題描述:
在SQL數(shù)據(jù)庫里已有一個現(xiàn)成的空數(shù)據(jù)表(只有字段、沒有數(shù)據(jù)),請問高手,怎樣在VB.NET中用SQL語句把該數(shù)據(jù)庫中的那個表復(fù)制一個到該數(shù)據(jù)庫(字段不變、數(shù)據(jù)為空)只是把數(shù)據(jù)表的名改了?
謝謝!謝謝!
解析:
select * into 新表 from 舊表
使用 SELECT INTO 插入行
SELECT INTO 語句創(chuàng)建一個新表,并用 SELECT 的結(jié)果集填充該表。新表的結(jié)構(gòu)由選擇列表中表達式的特性定義,例如:
SELECT Shippers.*, Link.Address, Link.City,
Link.Region, Link.PostalCode
INTO NewShippers
FROM Shippers
JOIN LinkServer.DB.dbo.Shippers AS Link
ON (Shippers.ShipperID = Link.ShipperID)
SELECT INTO 可將幾個表或視圖中的數(shù)據(jù)組合成一個表。也可用于創(chuàng)建一個包含選自鏈接服務(wù)器的數(shù)據(jù)的新表。
這個我是這么實現(xiàn)的.要用到
Excel.Application
Set xlapp = CreateObject("Excel.Application") '激活EXCEL
xlapp.Visible = True '讓EXCEL可見
Set xlbook = xlapp.Workbooks.Open(App.Path + "個人簡歷.xlt")
'打開工作簿,strDestination為一個EXCEL報表文件
Set xlsheet = xlbook.Worksheets(1) '設(shè)定工作表
這個有點像是vb6的、vb.net也有相應(yīng)的方法的.總之是
excel.application 用到這個就可以了.必要的話導(dǎo)入excel的dll文件.
這樣你就發(fā)現(xiàn)、可以用vb.net來對excel來操作.你可以查下微軟的msdn、有具體的屬性方法.
如:
Dim ef As New Excel.Application
Dim es As New Excel.Worksheet
Dim er As Excel.Range
ef.Workbooks.Add()
es = ef.Worksheets("sheet1")
es.Activate()
er = es.Range("a1:C1")
er.Select()
er.Merge()
er.Value = "gordon1117" ef.Visible = True 目前應(yīng)用了三個對象:application,worksheet和range,三者的關(guān)系應(yīng)該清晰,做到這點就能從基本開始做了:)格式設(shè)置都在range對象,只不過在設(shè)置對齊屬性上是verticalalignment和horizon
range 用來定位、
然后你可以循環(huán)把數(shù)據(jù)輸出到指定了格式的excel文件里了吧、其實連格式都是可以程序控制的好好學(xué)下吧.
可以參考一下這篇文章
asp.net 中將gridview數(shù)據(jù)導(dǎo)入到excel的類 usingSystem; usingSystem.Data; usingSystem.Configuration; usingSystem.IO; usingSystem.Web; usingSystem.Web.Security; usingSystem.Web.UI; usingSystem.Web.UI. WebControls; usingSystem.Web.UI. WebControls.WebParts; usingSystem.Web.UI. HtmlControls; ///summary /// ////summary publicclass GridViewExportUtil { ///summary /// ////summary ///paramname="fileName" /param ///paramname="gv"/ param publicstaticvoidExport( stringfileName,GridViewgv) { HttpContext.Current. Response.Clear(); HttpContext.Current. Response.AddHeader( "content- disposition",string.Format(" attachment;filename={0}", System.Web.HttpUtility. UrlEncode(fileName,System. Text.Encoding.UTF8))); HttpContext.Current. Response.ContentType=" application/ms-excel"; HttpContext.Current. Response.Charset="utf-8"; HttpContext.Current. Response.ContentEncoding= System.Text.Encoding. GetEncoding("utf-8"); using(StringWriter sw=newStringWriter()) { using( HtmlTextWriterhtw=new HtmlTextWriter(sw)) { //Createa formtocontainthegrid Tabletable= newTable(); //addthe headerrowtothetable if(gv. HeaderRow!=null) { GridViewExportUtil. PrepareControlForExport(gv. HeaderRow); table. Rows.Add(gv.HeaderRow); } //addeach ofthedatarowstothetable foreach( GridViewRowrowingv.Rows) { GridViewExportUtil. PrepareControlForExport(row); table. Rows.Add(row); } //addthe footerrowtothetable if(gv. FooterRow!=null) { GridViewExportUtil. PrepareControlForExport(gv. FooterRow); table. Rows.Add(gv.FooterRow); } //render thetableintothehtmlwriter table. RenderControl(htw); //render thehtmlwriterintothe response HttpContext. Current.Response.Write(sw. ToString()); HttpContext. Current.Response.End(); } } } 作者: 后天美麗 2007-8-31 09:24 回復(fù)此發(fā)言 2 回復(fù): asp.net 中將gridview數(shù)據(jù)導(dǎo)入到excel 的類 ///summary ///Replaceanyofthe containedcontrolswith literals ////summary ///paramname="control"/ param privatestaticvoid PrepareControlForExport( Controlcontrol) { for(inti=0;icontrol. Controls.Count;i++) { Controlcurrent=control. Controls[i]; if(currentisLinkButton) { control.Controls.Remove( current); control.Controls.AddAt(i, newLiteralControl((current asLinkButton).Text)); } elseif(currentis ImageButton) { control.Controls.Remove( current); control.Controls.AddAt(i, newLiteralControl((current asImageButton).AlternateText) ); } elseif(currentis HyperLink) { control.Controls.Remove( current); control.Controls.AddAt(i, newLiteralControl((current asHyperLink).Text)); } elseif(currentis DropDownList) { control.Controls.Remove( current); control.Controls.AddAt(i, newLiteralControl((current asDropDownList).SelectedItem. Text)); } elseif(currentisCheckBox) { control.Controls.Remove( current); control.Controls.AddAt(i, newLiteralControl((current asCheckBox).Checked?"True" :"False")); } if(current.HasControls()) { GridViewExportUtil. PrepareControlForExport( current); } } } }
不用這么麻煩。你
程序
記錄一下
版本號
,再根據(jù)版本號,把要更新的數(shù)據(jù)庫表
結(jié)構(gòu)
轉(zhuǎn)成
SQL
代碼,升級時執(zhí)行一遍就行了
網(wǎng)站名稱:vb.net復(fù)制sql表的簡單介紹
網(wǎng)站鏈接:http://www.yijiale78.com/article20/dooioco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、云服務(wù)器、虛擬主機、網(wǎng)站排名、關(guān)鍵詞優(yōu)化、網(wǎng)頁設(shè)計公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)