¤ÀÃþ |
¼ÐÃD |
¤j·N |
§@ªÌ |
¤é´Á |
SQL »yªk | ¥¿½TªºÄæ¦ìȬd¸ß®æ¦¡ | ¡@ | ¦Ñ©Ç | 1999/1/31 |
SQL »yªk | ¨âªí¦X¨Ö¡Aç°£«½ÆÁäÈÄæ¦ì¡C | ¡@ | ¦Ñ©Ç | 1999/1/31 |
SQL »yªk | ²£¥Í¦Pµ²ºcªÅ¥Õ¸ê®Æªí | ¡@ | ¦Ñ©Ç | 1999/3/7 |
SQL »yªk | ¤é´ÁÄæ¦ì§t®É¶¡ªº¬d¸ß | ¡@ | ¦Ñ©Ç | 1999/3/7 |
SQL »yªk | ¿é¤J¤ë¥÷¬d¸ß¾ã¤ë©Ò¦³°O¿ý | ¡@ | Fumi | 1999/3/7 |
SQL »yªk | ¥Î SQL °µÄæ¦ì±Æ§Ç | ORDER BY FieldName | ¦Ñ©Ç | 1999/4/16 |
SQL »yªk | °ÊºA¼W´îÄæ¦ì¬d¸ß | ¡@ | ¦Ñ©Ç | 1999/5/22 |
Dao ¾Þ§@ | Database ªº¶}¶}ÃöÃö | ¡@ | ¦Ñ©Ç | 1999/1/31 |
Dao ¾Þ§@ | ¤å¦rÀɸê®Æ®w¨Ï¥Î¤§ Schema.Ini ¸Õ§@ | ¡@ | ¦Ñ©Ç | 1999/3/12 |
Dao ¾Þ§@ | ¦b MDB ¸ê®Æ®w¤¤Ápµ²¨ä¥L«¬ºA¸ê®Æ®w | ¡@ | ¦Ñ©Ç | 1999/4/10 |
Dao ¾Þ§@ | §â MDB ªº¸ê®ÆªíÂð_¨Ó | Tabledef ªº Attributes Äݩʸs | ¦Ñ©Ç | 1999/4/23 |
Dao ¾Þ§@ | ¥Î TreeView ®i²{¸ê®Æ®w¤§¶¥¼hµ²ºc | ¡@ | ¦Ñ©Ç | 1999/5/8 |
Dao ¾Þ§@ | Index ª«¥óªº¨Ï¥Î¤Î¨î | ¡@ | ¦Ñ©Ç | 1999/6/7 |
Dao ¾Þ§@ | ¨ú±oÄæ¦ìªø«×¨ÃÁקK¿é¤J¶W¹Lªø«×¸ê®Æ | Field.Size | ¦Ñ©Ç | 1999/6/29 |
Dao ¾Þ§@ | §ó§ï MDB ¸ê®Æ®w±K½X | ¡@ | ¦Ñ©Ç | 1999/7/1 |
DBGrid | ¼W¥[ Columns Äæ¦ì(DataUnBound ª¬ªp) | Columns.Add ¤èªk | ¦Ñ©Ç | 1999/5/4 |
DBGrid | °»´ú¨Ï¥ÎªÌ Click ªºÄæ¦ì | Column.DataField ÄÝ©Ê | ¦Ñ©Ç | 1999/6/25 |
¸ê®Æ¤ÀªR | MDB ¸ê®Æªí¨Æ«eÃöÁp»P¨Æ«áÃöÁp | ¡@ | ¦Ñ©Ç | 1999/3/4 |
¸ê®Æ¤ÀªR | MDB Äæ¦ìªº¨Æ«e¯Á¤Þ»P¨Æ«á¯Á¤Þ | ¡@ | ¦Ñ©Ç | 1999/3/31 |
¸ê®Æ¤ÀªR | QueryDef ¹ï Relation ©M Index ªºÄ~©Ó | ¡@ | ¦Ñ©Ç | 1999/3/31 |
ÅKµ¡¤E¤¤§¤ñº¸·R´þ ¼¶¼g©ó¤å³¹
½Ð°Ý¥HVB¨Ó§ìMDBÀÉ¡A¦pªG¥HDATAª«¥ó¤è¦¡¨ÓÂ^¨ú¸ê®Æ¡A¦b§Ú¤U¤FDATA1.RECORDSET.CLOSE¤ÎDATA1.DATABASE.CLOSE«á¡A¬O§_ÁÙ¸ò¸ê®Æ®w³s¦b¤@°_¡A¦Ó¼vÅT¨ì¨ä¥LUSERªº¨Ï¥Î¡C
¦Ñ©Çµª¡G
ì«h¤W¤w²æÂ÷³sµ²¡A§Þ³N¤W§A«o«Ü¥i¯àÅý¥¦¤S³s¤W¡A¦¹¸Ü«çÁ¿¡A½Ð¬Ý¤U¨Ò¡G
Private Sub Command1_Click()
Data1.Recordset.Close
Data1.Database.Close
'**Data1.Refresh**
DBGrid1.Refresh
End Sub
§A§â¥´¬P¸¹ªº¨º¦æ¥ýµù°OÅý¥¦¥¢¯à¡A¨º»ò§Aµoı Command1 Click «á¡AªGµM¨ä¥Lµ{¦¡¥i¥H¶}¦P¤@ÀɮסA¦ý¦pªG§A§â¬P¸¹¨º¬q´_¯à¡A¨º§A·|µoı¡ACommand1 ±Ôz¦n¹³¤@ÂI§@¥Î³£¨S¦³¡C¨ä¹ê Data1 ¬O¦³Ãö¤F Recordset ©M Database ¡A¥u¬O¦b Refresh ±Ôz«á¡A¥¦¤S§â§A¦b³]p¶¥¬q³]©wªº¸ê®Æ«¶}¤F¤@¦¸¡Aµ²ªGÁÙ¬O¨SÃö±¼¡CSo¡Aª¾¹D«ç»ò¦^¨Æ¤F¶Ü¡C
ü..... ¼¶¼g©ó¤å³¹
§Ú¦³¤GÓ¸ê®Æ®wA,B¡AA¬O¥D¹q¸£¤Wªº¸ê®Æ®w,B¬O¥t¤@¹q¸£¤Wªº¸ê®Æ®w¡A²{¦b§Ú·Q§âB¦X¨Ö¨ìA¡A¦ý¬Onç°£«ÂÐÁäȪº¸ê®Æ¡A·Q°Ý¤@¤U¬O§_SQL¥i¥H°µ¨ì!
¦Ñ©Çµª¡G
¤£®¢©ó°Ý ¼¶¼g©ó¤å³¹
½Ð°ÝaccessªºÃöÁp¬O¦]¬°«Ø¥ß¬d¸ß(or from)»Ýn®É¤~¨Ì»Ýn³]©wÁÙ¬O,¥²¶·±N¦UÓÃöÁp¥þ³¡¥ý±µ³s°_¨Ó???
¦Ñ©Çµª¡G
·Qn½ö¦b©p¨Ãä ¼¶¼g©ó¤å³¹
¦p¦ó«Ø¤@Ó©M즳¸ê®ÆªíÄæ¦ì¬Û¦PªºªÅ¥Õ¸ê®Æªí¡C
¦Ñ©Çµª¡G
¤@ӳ̲³æªº¿ìªk¡A¥Î²£¥Í¸ê®Æªí Query °t¦X±ø¥ó±Ôz¡A¨Ó·s¼W¤@¸ê®Æªí¡A¦p¡G
SQLString="SELECT OldTable.* INTO NewTable FROM [OldTable] " _ &
"WHERE (((OldTable.SomeField)="¤@Ó¤£¥i¯à¥X²{ªºÈ"));"
¼s¹F·s¤@ ¼¶¼g©ó¤å³¹
½Ð°Ý ~~§Ún±N¤U¦CªºtextÀÉ©ñ¶i..VBªºDBGrid¤¤ªº¸Ü,Schema.ini¸Ó¦p¦ó³]£z?
11112222223333333 444444
11112222223333333 444444
11112222223333333 444444
§Ú·Qn¤À§O±N 1111 and 222222 and 3333333 and 444444¤À§O©ñ¦bDBGrid,§Ú¸Ó«ç»ò°µ§r?
¦Ñ©Çµª¡G
°±¤U¸}¨B ¥ð®§¤@¤U ¼¶¼g©ó¤å³¹
¦³¤@Ótable¥s SaleRecord¡A¦bSaleRecord¤¤¦³¤@ÓÄæ¦ì¥s SaleTime¡A>³oÓSaleTimeªº«¬§O¬O datetime °O¿ýµÛ®É¶¡©M¤é´Á¡A°²¦p§Ún¼g¤@ÓSQL«ü¥O§ä¥X¬Y¤Ñ¬Y®É(¨Ò¦p: 1999¦~1¤ë12¤é12:00)¥H«eªº¸ê®Æ¡A½Ð°Ý¸Ó«ç»ò¼g?
¦Ñ©Çµª¡G
Dim Db As Database
Dim Rs As Recordset
Dim SQLString As String
Set Db=OpenDatabase("Market")
SQLString="SELECT * FROM SaleRecord " & _
"WHERE SaleRecord.SaleTime < #1999/1/12 12:00:00# ;"
Set Rs =Db.OpenRecordset(SQLSTring)
'«Å§iªº³¡¤À¦p¤U:
Dim Db As Database
Dim Qd As QueryDef
Dim Rs As Recordset
Dim prmBeginDate As Parameter
Dim prmEndDate As Parameter
Set Db = OpenDatabase("Nwind.mdb")
Set Qd = Db.CreateQueryDef("", _
"PARAMETERS BeginDate DateTime, EndDate DateTime; " & _
"SELECT * FROM Orders " & _
"WHERE ShippedDate>=[BeginDate] AND ShippedDate<[EndDate]")
' Bind Parameter
Set prmBeginDate = Qd.Parameters("BeginDate")
Set prmEndDate = Qd.Parameters("EndDate")
'°õ¦æ¬d¸ßªº³¡¤À¦p¤U:
Dim QueryDate As Date
QueryDate = CDate("1994/08/10")
prmBeginDate = DateSerial(Year(QueryDate), Month(QueryDate), 1)
prmEndDate = DateSerial(Year(QueryDate), Month(QueryDate) + 1, 1)
Set Rs = Qd.OpenRecordset(dbOpenDynaset)
Do Until Rs.EOF
' Do something here
Rs.MoveNext
Loop
¥H¤U¥H DBF «¬ºA¸ê®Æ®w¬°¨Ò¡A¥Î Dao ª«¥ó¹ï©ó¤j«¬«D Jet MDB ¸ê®Æ®w¥i±Ä¥Î¥ý³sµ²¦A¬d¸ßªº¤è¦¡¡A½d¨Ò¦p¤U¡G
Dim Db As DataBase
Dim Td As TableDef
Dim Rs As Recordset
Set Db=OpenDatabase("§An»P DBF Àɳs±µªº MDB ¸ê®Æ®w")
'¦bnÀx¦s³sµ²ªº¸ê®Æ®w¤¤«Ø¥ß¤@Ó·sªº TableDef ª«¥ó¡C
Set Td = Db.CreateTableDef("¬°³s±µªí¨úÓ¦W¦r,Ä´¦p [OfficeTd]")
'³]©w©Òn³s½uªº¸ê®Æ®wªº«¬ºA¥H¤Î¸ê®Æ¨Ó·½ªº¦ì¸m¡C(n¥ý½T©w§A DBF Àɮ榡)
Td.Connect = "dBASE III(or dBASE IV or dBASE 5.0);DATABASE=\\Sales\Regional\Region1"
'±N SourceTableName ³]©w¬°·Qn¦s¨úªº DBF ÀɦWºÙ¡C
Td.SourceTableName = "Q1Sales"
'±N TableDef ·s¼W¨ì TableDefs ¶°¦Xª«¥ó¤¤¡C
Db.TableDefs.Append Td
'¥H¤W§¹¦¨ MDB »P DBF Connect
'¥Î SQL ±Ôz¶}±Ò³sµ²¸ê®Æªíªº Recordset¡C
Set Rs = Db.OpenRecordset ("SELECT * FROM OfficeTd WHERE Office='§An¬d¸ßªº
¤º®e';")
'§â Recordset ¥á¨ì DataControl ¦A§Q¥Î
Set Data.Recordset=Rs
¬Y ¼¶¼g©ó¤å³¹
§Úªº¸ê®Æ®w¤¤¦³¤@ӮɬqªºÄæ¦ì¡A¬O¤å¦r«¬ºA ¦p00~01¡A 02~03 ¦U¥Nªí¤@Ӯɬq¡A§Ú¦b·s¼W¨ì¸ê®Æªí®É¡A¦p¦óÅý¨ä«ö®É¬q¨Ó±Æ§Ç¡H
¦Ñ©Çµª¡G
SQLString="SELECT * FROM YourTableName ORDER BY ®É¬qÄæ¦ì¦W;"
§A¤j·§¤£ª¾¹D MDB ¸ê®Æ®w¥i¥H³o»òª±¡A¨º´N¬O¦b Access ¤¤¡A¥i¥HÅý¾ã±i Table Âð_¨Ó¡A©Ò¥H§A¥i¥H§â¨Ï¥ÎªÌ±K½X³]©wªº¨º±i¸ê®Æªí³]©w¥¦ªº Hidden ÄÝ©Ê¡AÅý¥Î Access ³nÅ餣Åã¥Ü¥X¨Ó¡A¦ý¦b VB µ{¦¡ùؤ´¥i¥H¥[¥H¾Þ§@¡A½d¨Ò¦p¤U¡G
Option Explicit
Dim Db As Database
Dim Td As TableDef
Set Db = OpenDatabase("YourDataPath&Name")
Set Td = Db.TableDefs("YourTableName")
Td.Attributes = Td.Attributes Or dbHiddenObject Or dbSystemObject
Db.Close
¹D»ª©¤µMªº¤w±B¨k ¼¶¼g©ó¤å³¹ ...
§Ú¿ï¥Î¤FDBgrid«á¡A¥L¥uÅã¥Ü¨â¦æ(column)¸ê®Æ¡A¦ý¬O§Úªº¸ê®Æ®w¨ä¹ê¦³¥|Ó¤£¦PÄæ¦ì¡A§ä¹M¤FDBgridªº¦UºØÄݩʳ£¨S¿ìªk§ï¡A§ä¨ì¹³DBgrid.Columns.countµ¥´XºØ¦³Ãöªº¸ê®Æ¡A¦ý³£ÄÝ©ó°ßŪ¡A½Ð°Ý¦³¤Hª¾¹D¦p¦ó¼W¥[DBgridªºÅã¥ÜÄæ¦ì¶Ü¡H
¦Ñ©Çµª¡G
¥Î Columns ¶°¦Xª«¥óªº Add ¤èªk¥h¼W¥[¡E½d¨Ò¦p¤U¡G
Private Sub Form_Load()
DBGrid1.Columns.Add DBGrid1.Columns.Count
DBGrid1.Columns(DBGrid1.Columns.Count - 1).Visible = True
End Sub
¨ä¥L½Ð°Ñ¦Ò Dbgrid.Columns.Add Help¡C
¥Î¤ßªº¨k¤H..28·³ ¼¶¼g©ó¤å³¹
¶â....°²¦p§Úªºdatabase¬O¥H¤U
id unit up_id
101 A 101
102 B 101
103 C 101
104 D 101
105 AA 102
106 AB 103
107 AC 102
108 AD 104
109 AE 102
110 BB 105
111 BC 106
112 BD 107
113 BE 108
114 BF 109
115 BG 107
116 BH 105
117 BI 108
¥H¤W¤§¸ê®Æ¦p¦ó§Q¥ÎTREEVIEW²£¥Í¾ðª¬µ²ºc¡H
¦Ñ©Çµª¡G
'´ú¸Õ¥»½d¨Ò½Ð©óªí³æ¥¬¸m TreeView
±±¨î¶µ¡A¨Ã¤Þ¥Î Dao ª«¥ó¡C
Option Explicit
Dim Db As Database
Private Sub Command1_Click()
Dim nodX As Node
Dim Rela As Long
Dim RsA As Recordset
Dim RsB As Recordset
Set RsA = Db.OpenRecordset("TabelName",
dbOpenDynaset)
Set RsB = RsA.Clone
RsA.MoveFirst
'«ÂI¤@¡G¦]¬°ÀY¤@µ§¬O®Ú Node¡A¬G
relative °Ñ¼Æ¤£¿é¡A®³¨ì
'°j°é¥~°µ¥t¥~³B²z¡C
'«ÂI¤G¡GKey
°Ñ¼Æ¤£¥u¤£±µ¨ü¼ÆÈ¡A³s IsNumeric
ªº¦r¦ê¤]¤£±µ¨ü¡A
'©Ò¥H¥u¦n¦b«á±¥[Ó "A"
¦r¤¸¡A¸ò³oÓ¹û§áªº TreeView §´¨ó¤@¤U¡C
Set nodX = TreeView1.Nodes.Add(, , RsA!ID
& "A", RsA!Unit)
RsA.MoveNext
Do While Not RsA.EOF
RsB.MoveFirst
RsB.FindFirst "ID
= '" & RsA!ID & "'"
'¦b¾ãÓTable ID
Äæ¦ìùاä§ä¬Ý¦³µL¥»µ§°O¿ý UpID È¡A¨Ó¨M©w¥»°O¿ý¬O
'Åܦ¨¤U¤@µ§©Î¥L°O¿ýªº¤l¶µ¥Ø¡C
If RsB.NoMatch Then
Rela = tvwNext
Else
Rela = tvwChild
End If
Set nodX = TreeView1.Nodes.Add(RsA!UpID
& "A", Rela, RsA!ID & "A",RsA!Unit)
RsA.MoveNext
Loop
End Sub
Private Sub Form_Load()
Set Db = OpenDatabase("DataPath&Name")
End Sub
Private Sub Form_Unload(Cancel As Integer)
Db.Close
End Sub
cheng ¼¶¼g©ó¤å³¹
°²³]¦b¤@ºô¶¤¤¥Î 5 Ó checkbox ±ø¥ó¡A¤]´N¬O¸ê®Æ®wªºÄæ¦ì A,B,C,D,E µ¹ user ¿ï¾Ü¡A¦p¿ïÄæ¦ì A,C,E ®É¬° Select A,C,E From DB¡A¤SY¿ïÄæ¦ì A,E ®É¬° Select A,E From DB¡A¸Ó¦p¦ó°µ¡H
¦Ñ©Çµª¡G
Private Sub Command1_Click()
Dim SQLString As String
Dim AddField As String
Dim I As Integer
SQLString = "SELECT "
For I = 0 To Check1.Count - 1
If Check1(I).Value Then
AddField = AddField & "Field" & CStr(I + 1) & ","
End If
Next
If Len(AddField) = 0 Then
MsgBox "¨S¦³¿ï¾Ü¥ô¦ó¬d¸ßÄæ¦ì"
Exit Sub
Else
AddField = Left(AddField, Len(AddField) - 1)
End If
SQLString = SQLString & AddField & " "
SQLString = SQLString & "FROM YourTableName;"
Debug.Print SQLString
End Sub
VBªì¾ÇªÌ
¦b EXCEL Ápµ²ªí¤¤¡A¬°¦ó DATA1.Recoderset.index="©m¦W" ¤@¥y³q¤£¹L?¡A??»Ýn¦p¦ó³]¸m¡H
¦Ñ©Çµª¡G
Data.Recordset.Index n¦³§@¥Î¡An¦³¤U¦C¤T±ø¥ó¡G
- ¥u¯à¨Ï¥Î¦b MDB «¬ºAªº¸ê®Æ®w¤¤¡C
- n§A¨º Table ½T¹ê¦³³]¨º¼Ëªº Index Name¡A§A¥i¥Î¤U¦Cµ{¦¡¬d¥X¸Ó Table ¦³¨º¨Ç¥i¥Îªº Index¡G
Option Explicit
Dim TD As TableDef
Private Sub Command1_Click()
Dim ID As Index
Set TD = Data1.Database.TableDefs("TableName")
For Each ID In TD.Indexes
Debug.Print ID.Name
Next
End Sub- ¥²¶· Data1.RecordsetType=dbOpenTable(0)¡A¨ä¥L Dynaset ©M Snapshot «¬ºAªºRecordset ³£¤£¾A¥Î¡C
- ©Ò¥H Dao ªº Index ª«¥ó¬O¬° MDB ¸ê®Æ®w¶q¨¥´³yªº¡A¹ï¨ä¥L§ÎºA¸ê®Æ®w¤ñ¸û¤£¾A¥Î¡A¦pªGn¯à¦s¨ú¦hºØ¸ê®Æ®w¡AÁÙ¬OÀ³¸Ó¨Ï¥Î SQL ¬d¸ß±Ôz¤¤ªº ORDER BY FieldName ©R¥O¤ñ¸û¦X¾A¡C
n´²¤ß,Oh..Ya... ¼¶¼g©ó¤å³¹
¦pªG§Ú¦³¤@ÓDBGrid,§Ú¥i¥Hª¾¹D¨Ï¥ÎªÌClick®É¬O«ö¨º¤@ÓÄæ¦ì¶Ü???
¦Ñ©Çµª¡G
Private Sub DBGrid1_Click()
Debug.Print DBGrid1.Columns(DBGrid1.Col).DataField
End Sub
²ïË稺°Õ~·s¦Ë ¼¶¼g©ó¤å³¹
½Ð°Ý¤@¤U¦b SQL Server ªºÀô¹Ò¤U¬O§_¦³´£¨Ñ¨ç¼Æ¥i¥Hª¾¹D¬YÓÄæ¦ì ªºªø«×¨î¶Ü¡H
¦Ñ©Çµª¡G
Debug.Print Recordset.Fields(Index).Size
²ïË稺°Õ~·s¦Ë
¤S¦pªGn¦bµ{¦¡¤¤Àˬd¨Ï¥ÎªÌ¿é¤JªºÄæ¦ì¬O§_¶W¹Lªø«×¡A¦³¨S¦³¤°»ò ¦n¿ìªk©O¡H
¦Ñ©Çµª¡G
'Field.Size ¬O¥H Byte ¬°³æ¦ìpºâ¡A¤@Ó¤¤¤å¨â Byte¡C
If LenB(StrConv("a¥[b¥[c", vbFromUnicode)) > Recordset.Fields(Index).Size Then
Exit Sub
Else
Recordset.Update
End If
¤ÑÃÈÃa¦Ñ¤½ ¼¶¼g©ó¤å³¹
¦p¦ó§ó§ïì¨Ó¦b MDB ¸ê®Æ®w³]©wªº±K½X¡H
¦Ñ©Çµª¡G
Option Explicit
Private Sub Command1_Click()
Dim Db As Database
'¸ê®Æ®wÀÉ®×n¥H¿W¦û¼Ò¦¡¶}±Ò¡A¥ç§Y²Ä¤GӰѼÆn¬° True ¡C
Set Db = OpenDatabase("c:\test\db1.mdb", True, False, ";pwd=NewPassword")
Db.NewPassword "OldPassword", "NewPassword"
Db.Close
End Sub