ado sqlserver ´æ´¢¹ý³Ì - MS-SQL Server / ÒÉÄÑÎÊÌâ
Õâ¸öÀý³ÌÊý¾Ý¿âpubs´æ´¢¹ý³Ìreptq1ÄÜÕýÈ·Ö´ÐУ¬
¸Ä³É×Ô¼ºµÄÊý¾Ý¿âºÍ´æ´¢¹ý³Ì¾Í±¨´í3704£¨Ó¦ÓóÌÐò¶¨Òå»ò¶ÔÏó¶¨Òå´íÎó£©
´æ´¢¹ý³ÌÔÚ²éѯ·ÖÎöÆ÷ÄÜÕýÈ·Ö´ÐУ¬¶øÇÒÒ»Ö±ÔÚÓõģ¬ÕæÊÇÔÎËÀ¡£
Private Sub CommandButton5_Click()
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim adocmd As New ADODB.Command
Dim SQL As String, mydata As String
Dim i As Integer
cnn.ConnectionString = "Provider = SQLOLEDB.1;Data Source = ibm;Initial Catalog = pubs;User ID =sa;Password =;"
cnn.Open
Set adocmd.ActiveConnection = cnn 'ָʾָ¶¨µÄ Command¶ÔÏóµ±Ç°ËùÊôµÄ Connection¶ÔÏó
adocmd.CommandText = "reptq1" 'ÉèÖÃCommand¶ÔÏóÔ´
adocmd.CommandType = adCmdStoredProc '֪ͨÌṩÕßCommandTextÊôÐÔÊÇ´æ´¢¹ý³Ì
Set rs = adocmd.Execute
Cells.Clear
For i = 0 To rs.Fields.Count - 1
Cells(1, i + 1) = rs.Fields(i).Name
Next i
Range("a2").CopyfromRecordset rs
Cells.Columns.AutoFit
rs.Close
cnn.Close
Set rs = Nothing
Set cnn = Nothing
End Sub
¼ì²éһϴ洢¹ý³ÌÖзµ»ØµÄ×Ö¶ÎÃûÊÇ·ñºÍÇ°¶ËÒýÓõķûºÏ
ÔÚ×Ô¼ºÊý¾Ý¿â´´½¨Ò»¸ö¼òµ¥Ò»µãµÄ´æ´¢¹ý³ÌÒ²ÄÜÖ´Ðеģ¬ÄѵÀÊÇÏÂÃæ´æ´¢¹ý³ÌÊǶ¯Ì¬µÄÔÒò£¿
CREATE PROCEDURE smzls_tzd AS
create table #t(userid nvarchar(12),nmtabnum int,amtabnum int,watermete decimal,totmoneydx decimal(10,2),intabmanname nvarchar(10))
declare @sql varchar(8000)
select @sql
Ïà¹ØÎÊ´ð£º
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
sqlserver2005 ½¨Á¢µÄÊý¾Ý¿â£¬ÓëÊÖ³Öpda´«ÊäÊý¾Ý£¬×î½üͻȻ³öÏÖÎÞ·¨´«µÝÊý¾ÝµÄÎÊÌ⣬pda¶ËÌáʾµÄ´íÎóʱoutofmemoryexception£¬µ«ÊÇpdaÉÏÃæµÄÈÝÁ¿Ã»ÓÐÎÊÌ⣬
sqlserverµÄÈÕ×ÓÉϵĴíÎóÈçÏ£º
ÈÕÆÚ 2010-1-25 14:45: ......
1¡£ÔõÑùʹxp_cmdshellÄÜÍêÕûÊä³ö³¬¹ý255¸ö×Ö·ûµÄ×Ö·û´®¡£
2¡£select ʱ£¬¼ìË÷ËÙ¶ÈÊÇÓëfromºóµÄ TABLE˳ÐòÓйأ¬»¹ÊÇÓëwhereÌõ¼þµÄ˳ÐòÓйØ(TABLEÊý¾Ý¶àÉÙ )
ÔÚϵͳÊôÐÔÉ趨ÀïÓиöÑ¡Ïî,¿ÉÒÔÐ޸ĵ¥×Ö¶ÎÊä³ö×ÖÊýÏÞÖÆ. ......