Dao »P SQL »yªk½d¨Ò(¤T)

¦^­º­¶


¤ÀÃþ

¼ÐÃD

¤j·N

§@ªÌ

¤é´Á

Dao ¾Þ§@ ³v¨B¨ú¦^¤j«¬¸ê®Æ®wªº°O¿ý ¡@ ¦Ñ©Ç 1998/11/13
Dao ¾Þ§@ ³]©wÄæ¦ìªº¹w³]­È Field.DefaultValue Äݩʪº¨Ï¥Î ¦Ñ©Ç 1998/11/13
Dao ¾Þ§@ ¦p¦ó§â FieldValue ©ñ¨ì ComboBox ùØ Recordset °j°éªº»s§@ ¦Ñ©Ç 1998/11/18
Dao ¾Þ§@ ¥Î ComBo ¾Þ§@¨â­ÓÄæ¦ì°O¿ý ItemData ÄݩʨϥΠ¦Ñ©Ç 1999/1/22
Dao ¾Þ§@ Åý¨â­Ó Combo ¨Ì Record ³s°Ê ¡@ ¦Ñ©Ç 1998/11/26
Dao ¾Þ§@ Recordset.Filter ©M SQL WHERE ªº¨Ï¥Î Recordset ªº±ø¥ó¬d¸ß ¦Ñ©Ç 1998/11/28
Dao ¾Þ§@ ¦p¦óÁÙ­ì¤é´ÁÄæ¦ì¬°¥¼¿é¤J«¬ºA FieldName.Value=Null ¦Ñ©Ç 1999/1/16
Dao ¾Þ§@ ¶}±Ò¸ê®Æ®w¤¤¥ô¤@¸ê®Æªí TabDefs ¶°¦Xª«¥ó¨Ï¥Î ¦Ñ©Ç 1999/2/12
SQL »yªk ¦C¥X¯S©w®É¶¡°Ï¬qªº©Ò¦³°O¿ý Between ªº±ø¥ó¬d¸ß ¦Ñ©Ç 1998/12/3
SQL »yªk ¬°¸ê®Æ°O¿ý°µ¸s²Õ¤À¶µ²Î­p GROUP BY ±Ô­z ¦Ñ©Ç 1999/1/20
SQL »yªk ±N³s±µªººô¸ô¸ê®Æªí¦s¤J¥»¾÷¸ê®Æ®w ²£¥Í¸ê®Æªí¬d¸ßªº¨Ï¥Î ¦Ñ©Ç 1999/1/22
SQL »yªk ¦b SQL ¦r¦ê¤¤´¡¤J ['] ¦r¤¸ Chr(Ascii Code) ªº¨Ï¥Î ¦Ñ©Ç 1999/1/28
DBGrid ¨â­Ó¤£¦P³]©wªº DBGrid ¦P¨B Columns.Visible Äݩʪº§Q¥Î ¦Ñ©Ç 1998/11/19
DBGrid Àx¦s DBGrid.Columns.Width ªº³]©w Field.Property ª«¥óªº§Q¥Î ¦Ñ©Ç 1998/11/19
DBGrid ³]©wÄæ¦ì¦WºÙ Column.Caption Äݩʪº¨Ï¥Î ¦Ñ©Ç 1998/12/15
DBGrid ¦C¦L DBGrid Cell ùتº¸ê®Æ(1999/4/3 ­×¥¿) DBGrid.CellText ¤èªkªº¨Ï¥Î ¦Ñ©Ç 1998/12/31
DBGrid ¦hÄæ¤Î¦h¦C¿ï¨ú ¡@ ¦Ñ©Ç 1999/1/4
DBList ¥Î DBList_Click ²¾°Ê°O¿ý«ü¼Ð SelectItem Äݩʪº¨Ï¥Î ¦Ñ©Ç 1998/12/25
¸ê®Æ¤ÀªR À³·í¤À³Îªº¸ê®Æªí ¸ê®Æ²Ó¤ÀªºÆ[©À ¦Ñ©Ç 1998/12/15
¸ê®Æ¤ÀªR ¦A½Í¸ê®Æ®wÄæ¦ì¤¤ Null ­Èªº³B²z ¸ê®Æ®w¦w¥þ»P¨Ï¥ÎªÌ«K§Q ¦Ñ©Ç 1999/1/16

Dao »P SQL »yªk½d¨Ò¨Ï¥Î»¡©ú


  1. ¥»¸ê®Æ®w½d¨Ò¥u¾A¥Î Dao ª«¥ó¡A³æ¤@¨Ï¥ÎªÌªº¾Þ§@¡A¦h¨Ï¥ÎªÌ¤Îºô¸ô¤Wªº¨Ï¥Î¡A¦]¦³§ó¦hªº­­¨î¡A¥»½d¨Ò¥¼¥²¯à¥¿½T°õ¦æ¡C¥»½d¨ÒÅwªï«DÀç§Q©Ê­Ó¤H¤Î²Õ´Âà¸ü¨Ï¥Î¡AÀç§Q¤§§Q¥Î½Ð¥ý¼x±o¥»¤H¤§¦P·N¡A¨Ó«Hµù©ú¨Ï¥Î¤è¦¡¤Î¦^ÂЦa§}¡C
  2. DBGrid¡BDBCombo ÁöÄÝ VB ¥~«Ø±±¨î¶µ¡A¦ý¦]»P Dao ¸ê®Æ®w®§®§¬ÛÃö¡A©Ò¥H¤]©ñ¥»½g°Q½×¡A¦Ó¤£¥¦ÂkÃþ¦b ActiveX ¶µ¡C
  3. ¥»½d¨Ò©Ò¦³ªºµ{¦¡½X½d¨Ò¡A¬ÒÄݤQ¤À°ò¥»ªº VB »yªk¡A¦pªG±z¬O­Ó VB User ¡AÅwªïª½±µ¤Þ¥Î©Î§ï¼g¨Ï¥Î¦b§Aªºµ{¦¡¤¤ ¡A¥»¤H¤£¥D±iµÛ§@Åv¡A¦]¬°¡A¨S¿ìªk¬d¹À¡C
  4. ¦pªG§A¬O­Ó VB ªì¾ÇªÌ¡A¤S¦³ÂI½a½a(©M¦Ñ©Ç¤@¼Ë)¡A»°§Ö§â¥»­¶¥t¦s·sÀɨì§A¦Û¤vªººÏºÐ¡AÂ÷½u«áºCºC¬Ý¡A¤]¥i¥H Copy µ¹ªB¤Í³á(¤£¥i¥H¦¬¿ú)¡C
  5. ¥»½d¨Ò³£¬O¦Ñ©Ç´X­Ó¤ë¨Ó¦b tw.bbs.comp.language °Q½×¸s²Õ¤¤¦^µªª©¤Í°ÝÃDªº¦X¿è¡A¦]¬°¬O°w¹ï°ÝÃD¸Ñ¨M¡A©Ò¦³¨Ã¨S¦³¥þ­±Æ[©Àªº¸Ñ»¡¡A¤£¾A¦X§@¬°¤Jªù¤å³¹¡A¦ý¦pªG§AŪ¤F¤Jªù®Ñ¡A©Î¬O¤W¤F¦Ñ®vªº½Ò¡A¤ß¤¤¤´¤£¬Æ©ú¥Õªº¸Ü¡A´N¥i¥H¨Ó³o§ä§ä¦³¨S¦³§A­nªºµª®×¡A¦]¬°³o³£¬O§O¤H°Ý¹Lªº°ÝÃD¡C

¦^¯Á¤Þ


³v¨B¨ú¦^¤j«¬¸ê®Æ®wªº°O¿ý


JMilk ¼¶¼g©ó¤å³¹

§Ú­n¨ú¦^¸ê®Æ®w¤¤¤@¤j¦ê¸ê®Æ, ¥i¬O, ¨C¨C³£³y¦¨¹O®É.©Ò¥H, §Ú·Q­n¥Î record set ªº¤À­¶§Þ¥©, ¤@¤p³¡¥÷¤@¤p³¡¥÷ªº®³¦^¨Ó.·Ð½Ð½ç±Ð.

¦Ñ©Çµª¡G

  1. §A¥ý¦b DataTable ùØ¿ï©w¤@­Ó PrimaryKeyField¡C
  2. ¥²¶·¨Ï¥Î SQL TOP ±Ô­zªº¥\¯à¡C
  3. ³B²zªº¼Ò«¬¬O³o¼Ëªº¡G
    Dim Db As DataBase
    Dim Rs As Recordset
    Dim Td As TabelDef
    Dim SQLString As String
    Dim TotalCount As Long
    Dim CalcCount As Long
    Dim SeperatKey

    Set Db =OpenDataBase("YourDataBase")
    Set Td=Db.TabelDefs("TabelName")
    TotalCount =Td.RecordCount

    SQLString="Select Top 100 Field(1),Field(2)... Form YourTable Order by
    PrimarykeyField"
    Set Rs=Db.OpenRecordset(SQLString)
    CalcCount=CalcCount+100

    Do While CalcCount<TotalCount
        Rs.MoveLast
        SeperateKey=Rs!PrimaryKeyFieldName
        SQLString="Select Top 100 Field(1),Field(2)... Form YourTable Where
    PrimaryKeyField > "
        & SeperateKey & " Order by PrimarykeyField"
        Set Rs=Db.OpenRecordset(SQLString)
        CalcCount=CalcCount+100
        '§Aªº¸ê®Æ³B²z°Ê§@.....
        '.....................................
        '.....................................
    Loop
  4. ­«ÂI¬O¨Ì¬Y¤@ PrimaryKey ±Æ§Ç«á¤@¦¸¶}¦³­­ªºµ§¼Æ¡A¦A§â³Ì«á¤@µ§°O¿ýªº PrimaryKey ­È·í°µ¤U¤@´`Àô¶}±Ò°O¿ý¤§Where ±ø¥ó¡A§A´N¥i¥H³v¬q§â°O¿ý©¹¤U²¾¡A¤£·|Á`¬O±q²Ä¤@µ§¶}©l¡C

¦^¯Á¤Þ


³]©wÄæ¦ìªº¹w³]­È


±H¥óªÌ: sam

¤é´ÁªºÄæ¦ì¡A¦b¨Ï¥Î¥Lªº®É­Ô§Ú·Q³]©w¬°·í¤éªº¤é´Á¡A¦ý·íÀx¦s«á¡A§Ú¤£·Q¥L¦A¸ò¤é´Á¦Ó§ï¡A½Ð°Ý­n¦p¦ó°µ©O¡H

¦Ñ©Çµª¡G

  1. ¥Î Access 97 Table ªº³]­p¥\¯à¡A¦b¤é´ÁÄæ¦ìªº¹w³]­È¨ºÄæ¦ìùØ¥´ "Date()"¡C
  2. ¥Î VB Code
    Dim Db As Database
    Dim Td As TableDef
    Dim Fd As Field
        Set Db = OpenDatabase("YourDataPath&Name")
        Set Td = Db.TableDefs("YourTableName")
        Set Fd = Td.Fields("YourDateTypeFieldName")
        Fd.DefaultValue = "Date()"
  3. ³oºØ¥Îªk¥u¯à¥Î¦b Jet MDB ¸ê®Æ®w¡C
  4. ¦pªG¬O¥´Âà´«¨ç¼Æ¦r¦ê¡AÀ³¸Ó¥ý¬d²M·¡ Access ª©¥»¦³¨S¦³¤ä´©¦¹Ãþ¨ç¼Æ¡A¨ç¼Æ¦WºÙ¬O«ü Access ¨ç¼Æ¡A¦Ó¤£¬O VB ¨ç¼Æ¡C

¦^¯Á¤Þ


¦p¦ó§â FieldValue ©ñ¨ì ComboBox ùØ


¦w´µ¯Pº¸ ¼¶¼g©ó¤å³¹

¦p¦ó¥ÎComboª«¥ó¡A±NDataBase¤¤ªºRecordSource¥þ³¡Åª¥X¨Ó¡A°µ¦¨AddItemªº¤è¦¡¡C

¦Ñ©Çµª¡G

Dim Db as database
Dim Rs as recordset

set Db=opendatabase("YourDataPath&Name")
set Rs=Db.openrecordset("yourtablename")

Rs.MoveFirst

Do While Not Rs.Eof
    combo1.additem Rs!"YourFieldName"
    Rs.MoveNext
Loop

¦^¯Á¤Þ


¨â­Ó¤£¦P³]©wªº DBGrid ¦P¨B


linux ¼¶¼g©ó¤å³¹

§Ú¸ÕµÛ¨â­Ó form ¶}¤£¦Pªº DBGrid¡A¥Î¦P¤@­Ó Data Table ¡A¦ý¤@­Ó¥uÅã¥Ü¤@¨ÇÄæ¦ì , ¤@­Ó¥þ³¡³£Åã¥Ü¡A¦ý§ÚµLªk¦P¨B»¡¡C¨Ò¦p : movenext ,moveprevious,movelast,movefirst ¤@¦¸²¾¨â­Ó DBGrid ªº°O¿ý«ü¼Ð¡H

¦Ñ©Çµª¡G

Form1¡G
§â Data1 ªº DataBaseName ©M ReCordSource ³]¦n¡C

Form2¡G
    Set Data1.Recordset = Form1.Data1.Recordset
   
    '§â¤£­n¦b DBGrid ùØÅã¥ÜªºÄæ¦ìÂð_¨Ó
    DBGrid1.Columns("Field2Name").Visible = False
    DBGrid1.Columns("Field3Name").Visible = False
    DBGrid1.Columns("Field4Name").Visible = False

¦^¯Á¤Þ


Àx¦s DBGrid.Columns.Width ªº³]©w


Paper Crane ¼¶¼g©ó¤å³¹

¥Î DBGrid ¬Ý¸ê®Æ®É, ¨C¦¸³£­n¥Î·Æ¹«¥h½ÕÄæ¦ì¼e«×¡A¨º­n«ç¼Ë¤~¯à§â½Õ¦nªº¦ì¸m¦s°_¨Ó ? ¤£µM¨C¦¸³£­n¦A½Õ¤@¦¸¡AÄÝ©ÊÄæ¸Ì¦n¹³¨S¿ìªkÀx¦s³o¶µ¸ê®Æ£z£®¡I

¦Ñ©Çµª¡G

DBGrid1.Columns(Index).Width ÄÝ©ó°õ¦æ´Á³]©w¤§ÄÝ©Ê¡A¨S¿ìªk«O¯d¨ì¤U¦¸±Ò°Êµ{¦¡®É¡C¹ê»Ú¤W Data ©M DBGrid ³£¨S¦³³oºØÄݩʳ]©w¡A¤£¹L§Ú­Ì¥i¥H§â DBGrid ªº ColumnWidth ¸ê®Æ°O¨ì MDB ¸ê®Æ®wªº Properties ¶°¦XùØ¡A«Ü¤Ö¬Ý¨ì VB ¤Í¥Î MDB Property ª«¥óªº¡A³oªF¦è¥i¥H CreatNew ¡A¥i¥H Read and Set (­n¬ÝÄݩʪ¬ªp¡A¤£¬O©Ò¦³³£¾A¥Î¡C)½Ð°Ñ¦Ò¥H¤U½d¨Ò¡C
'¥»½d¨Ò¬O§Q¥Î Dao Field ª«¥óªº Propertys ¶°¦Xùتº ColumnWidth ÄÝ©Ê
'¨Ó°O¿ý DBGrid ªº ColumnWidth ­È¡A¨Ï±o¨Ï¥ÎªÌ§ïÅÜ DBGrid ªº ColumnWidth
'¥i¥H«O¦s¤U¨Ó¡A¦b¤U¦¸±Ò°Ê®Éºû«ù­ì¨Óªº³]©w¡A­nª`·Nªº¬O ColumnWidth ªº­È
'¤£¦b Data ©M DbGrid ÄÝ©ÊùØ¡A¦Ó¬O¦s©ñ¦b MDB ¸ê®Æ®w¥»¨­¡A³oºØ§ïÅܤΩó
'¥H Access ¶}±Òªº Table¡C
'´ú¸Õ¥»½d¨Ò½Ð©óªí³æ¤W¥¬¸m Data1,Dbgrid1
Option Explicit
Dim Db As Database
Dim Rs As Recordset
Dim Td As TableDef
'¶}±Ò¸ê®Æªí¤§¦WºÙ
Dim TDName As String
'¨ú¥X ColumnWidth ªº Property.Value
Private Function GetCellWidth(TempFd As Field) As Single
    '¦pªG ColumnWidth ªº Property.Value µ¥©ó¹w³]­È¡A«h¥ýÅý
    'DBGrid ªº ColumnWidth =1500
    If TempFd.Properties!ColumnWidth.Value = -1 Then
        TempFd.Properties!ColumnWidth.Value = 1500
        TempFd.Properties.Refresh
    End If
   
    GetCellWidth = TempFd.Properties!ColumnWidth.Value
End Function
'¦pªGµo¥Í ColResize ¨Æ¥ó«h³]©w ColumnWidth ªº Property.Value
Private Sub DBGrid1_ColResize(ByVal ColIndex As Integer, Cancel As Integer)
    SetCellWidth DBGrid1.Columns(ColIndex).DataField, _
            DBGrid1.Columns(ColIndex).Width
End Sub
Private Sub Form_Load()
    TDName = "Student"
    Set Db = OpenDatabase("C:\test\mytest.mdb")
    Set Rs = Db.OpenRecordset(TDName)
    'TabelDef ¦b¦¹³B¤£¯à¥Î Recordset ¥N´À¡A¦]¬° Field.Propertis ¥u¦³¥Î
    'TabelDef ¤Î QueryDef ¤~¯à°Ñ·Ó¨ì¡A¥Î Recordset ¨Ó°Ñ·Ó·|¦³µLªk³]©wªº
    '¿ù»~
    Set Td = Db.TableDefs(TDName)
   
    Set Data1.Recordset = Rs
    GetAllColWidth
End Sub
'¨ú±o¥ý«eÀx¦s Filed.Properties!ColumnWidth ªº Value
Private Sub GetAllColWidth()
Dim I As Integer
Dim SendField As Field
    For I = 0 To DBGrid1.Columns.Count - 1
        Set SendField = Td.Fields(DBGrid1.Columns(I).DataField)
        DBGrid1.Columns(I).Width = GetCellWidth(SendField)
    Next
End Sub
Private Sub Form_Unload(Cancel As Integer)
    Rs.Close
    Db.Close
End Sub
'³]©w ColumnWidth ªº Property.Value
Private Sub SetCellWidth(ByVal FDName As String, ByVal CellWidth As Single)
    Td.Fields(FDName).Properties!ColumnWidth.Value = CellWidth
    Td.Fields(FDName).Properties.Refresh
End Sub

¦^¯Á¤Þ


Åý¨â­Ó Combo ¨Ì Record ³s°Ê


Zima T. ¼¶¼g©ó¤å³¹

­Y§Ú¥Î¨â­Ó comboxA & comboxB ¦P®É¤]³£³sµ²¸ê®Æ®w field1 & Field2¡A·í§Ú¿ï¨ú comboxA(comboxB) ªº¶µ¥Ø®É ¦p¦óÅý comboxB(comboxA) ªº¸ê®Æ¤]¦P®É°µÅÜ°Ê©O?

¦Ñ©Çµª¡G

Option Explicit
Private Sub Combo1_Click()
Dim SearchNo As Long
Dim I As Long
    SearchNo = Combo1.ItemData(Combo1.ListIndex)
   
    For I = 0 To Combo2.ListCount - 1
        If Combo2.ItemData(I) = SearchNo Then
            Combo2.ListIndex = I
            Exit For
        End If
    Next
End Sub
Private Sub Combo2_Click()
Dim SearchNo As Long
Dim I As Long
    SearchNo = Combo2.ItemData(Combo2.ListIndex)
   
    For I = 0 To Combo1.ListCount - 1
        If Combo1.ItemData(I) = SearchNo Then
            Combo1.ListIndex = I
            Exit For
        End If
    Next
End Sub

Private Sub Form_Activate()
    Data1.Recordset.MoveFirst
   
    Do While Not Data1.Recordset.EOF
        Combo1.AddItem Data1.Recordset!Name
        '¥»½d¨Òªº­«ÂI¬O PrimaryKey Serial Äæ¦ì¬O¤@ªø¾ã¼Æ«¬ºA
        '§Y¥i§â¥L¥[¦b ItemData ùØ°µ¯Á¤Þ
        Combo1.ItemData(Combo1.NewIndex) = Data1.Recordset!Serial
        Combo2.AddItem Data1.Recordset!Note
        Combo2.ItemData(Combo2.NewIndex) = Data1.Recordset!Serial
        Data1.Recordset.MoveNext
    Loop
   
    Combo1.ListIndex = 0
    Combo2.ListIndex = 0
End Sub

¦^¯Á¤Þ


Recordset.Filter ©M SQL WHERE ªº¨Ï¥Î


±H¥óªÌ: Young Team Inc.

§Ú»s§@¤F¤@­Ó¦³Ãö¬d¸ßªºµ{¦¡(¸ê®Æ¬ù¤@¸Uµ§)¡A¦b§@±ø¥ó¬d¸ß®ÉÁö¦³§Q¥Î¨ì¯Á¤Þ¦ý³t«×ÁÙ¬O«ÜºC¡FVB¤¤¦³­Ó Filter ªº¥\¯à¦n¹³¤£¿ù¡A¦ý§Ú¬Ý¤£¤ÓÀ´¨Ï¥Î»¡©ú¡A¤£ª¾¥i§_±Ð±Ð§Ú¦³Ãö Filter ªº¹B¥Î¡AÁÂÁ¡C

¦Ñ©Çµª¡G

Option Explicit
Dim Db As Database
Dim Rs As Recordset
Dim Rs1 As Recordset
'§Q¥Î Recordset.Filter Äݩʧ@±ø¥ó¬d¸ß
Private Sub Command1_Click()
    Rs.Filter = "Name Like '*D*'"
    Set Rs1 = Rs.OpenRecordset
    Set Data1.Recordset = Rs1
End Sub
'§Q¥Î SQL WHERE ±Ô­z§@±ø¥ó¬d¸ß
Private Sub Command2_Click()
Dim SQLString As String
    SQLString = "SELECT * FROM Student WHERE Name LIKE '*D*'"
    Set Rs1 = Db.OpenRecordset(SQLString)
    Set Data1.Recordset = Rs1
End Sub
Private Sub Form_Load()
    Set Db = OpenDatabase("c:\test\mytest.mdb")
    '¥²¶·«ü©w Recordset ¶}±Ò«¬ºA¬°
    'dynaset
    'snapshot
    'forward-only
    'Filter property ¤~¯à¨Ï¥Î
    Set Rs = Db.OpenRecordset("student", dbOpenDynaset)
   
    Set Data1.Recordset = Rs
End Sub
Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    Rs.Close
    Rs1.Close
    Db.Close
End Sub

¨Ï¥Î Filter ©M Where ±Ô­z³Ì«áªºµ²ªG¬O¤@¼Ëªº¡A¦ý¦] Filter ¥u¯à¾A¥Î Jet MDB ¸ê®Æ®w¡A¬°¤Fµ{¦¡ªº³q¥Î©Ê¡AÁÙ¬O¥Î WHERE ±Ô­z¤ñ¸û¦n¡C

¦^¯Á¤Þ


¦C¥X¯S©w®É¶¡°Ï¬qªº©Ò¦³°O¿ý


®ü¼Ü§g ¼¶¼g©ó¤å³¹

§Ú·Q¥Ñ :select * from table1.db where [TDate] like "1998/4/*"¨Ó§ä¥X¥|¤ë¥÷ªº©Ò¦³¸ê®Æ.....

¦Ñ©Çµª¡G

select * from table1.db where [TDate] Between #1998/4/1# And #1998/4/30#

¦^¯Á¤Þ


À³·í¤À³Îªº¸ê®Æªí


¯è¦V¹Ú·Qªº¤Ñ°ó ¼¶¼g©ó¤å³¹

¨Ò¦p:¦³¤@¥x¤½¨® ¨ä¤½¨®¸¹½X©M¥¦¦æ¸gªº¦U¯¸¦W­n¦p¦ó³B²z©O?
>        ¤½¨®¸¹½X  |    from    |    to
>        ----------------------------
>        287       |  ¤¤¤s¥«³õ  |  ¥x¥_¨®¯¸
>        287       |  ¥x¥_¨®¯¸  |  «n¶§µó
>        247       |  ¤j¦P¤½¥q  |  ¥xªd¤j¼Ó
>        247       |  ¥xªd¤j¼Ó  |  ¬ü³NÀ]
>        247       |  ¬ü³NÀ]    |  ¤jª½

¦Ñ©Çµª¡G

  1. ¦pªG¬O§Ú¡A§Ú·|¥Î¨â­Ó¸ê®Æªí¨Ó°µÃöÁp¡G
  2. ¤@¡B¸ô½uªí¡G
    ¸ô½u½s¸¹  |    from    |    to
    ----------------------------
    001       |  ¤¤¤s¥«³õ  |  ¥x¥_¨®¯¸
    002       |  ¥x¥_¨®¯¸  |  «n¶§µó
    003       |  ¤j¦P¤½¥q  |  ¥xªd¤j¼Ó
    004       |  ¥xªd¤j¼Ó  |  ¬ü³NÀ]
    005       |  ¬ü³NÀ]    |  ¤jª½
  3. ¤G¡B¤½¨®ªí¡G
    ¤½¨®¸¹½X  |¸ô½u½s¸¹
    ----------------------------
    287       |001
    287       |002
    287       |003
    247       |003
    247       |004
    247       |005
  4. ¦C¥X¬Y¸¹¤½¨®¸g¹L¨º¨Ç¸ô¬q
    SQLString="Select ¤½¨®ªí.¤½¨®¸¹½X,¸ô½uªí.from,¸ô½uªí.to From ¤½¨®ªí Inner
    Join ¸ô½uªí On ¤½¨®ªí.¸ô½u½s¸¹=¸ô½uªí.¸ô½u½s¸¹ Where ¤½¨®ªí.¤½¨®¸¹½X = " &
    varBusNo & ";"
  5. ¦C¥X¬Y¸ô¬q¦³¨º¨Ç¤½¨®¸g¹L
    SQLString="Select ¤½¨®ªí.¤½¨®¸¹½X,¸ô½uªí.from,¸ô½uªí.to From ¸ô½uªí Inner
    Join ¤½¨®ªí On ¸ô½uªí.¸ô½u½s¸¹=¤½¨®ªí.¸ô½u½s¸¹ Where ¸ô½u½s¸¹.¸ô½u½s¸¹ = " &
    varsStreetNo & ";"
  6. §ó­«­nªº¬O§AÀ³¸Ó¦³¸ô½u²Ó¤ÀªºÆ[©À¡A§Úı±o¥ô¦ó¨â­Ó¯¸µP¶¡³£­nºâ°µ¤@¬q¡AÄ´¦p±q¤Ñ¥À¨ì­û¤s¡A¸g¹L¤hªL°ê¤¤¡B»Ê¶Ç¤j¾Ç¡B«OÄÖ²yÀ]¨ì­û¤s¤j¶º©±¡A¦pªG§AÅ¢²Îªº§â¤Ñ¥À¨ì­û¤s¦C¬°¤@¬q¡A¨º¦³±qªÀ¤l¨ì¤hªL°ê¤¤ªº¨®¤l¡A¦b¸ê®Æ®w¤W¬O¨S¦³¥æ¶°¡A¥i¬O¦b¹ê»Ú¸ô½u¤W¬O¦³­«Å|ªº¡C¸ê®Æ®w³]­p¡A¤£¥u¦ÒÅçµ{¦¡¤Î¸ê®Æ¤ÀªR¡A¤]¦ÒÅç§A¹ï²{¹ê¨Æª«¤ÀªRÂk¯Çªº¯à¤O¡C

¦^¯Á¤Þ


³]©wÄæ¦ì¦WºÙ


°Õ°Õ°Õ ¼¶¼g©ó¤å³¹

§Ú¶}±Òdbgrid³o­Ó±±¨î¶µ®É¡A¨º§Ú­n¦p¦ó¦b¨C¦æªº¦æ­º¿é¤JÄæ¦ì¦WºÙ©O??

¦Ñ©Çµª¡G

¨Ï¥Î DBGrid ªº Column ª«¥óªº Caption Äݩʦp¡G
Private Sub Form_Activate()
    DBGrid1.Columns(0).Caption = "µ¹­ÓÄæ¦W"
End Sub

¦^¯Á¤Þ


¥Î DBList_Click ²¾°Ê°O¿ý«ü¼Ð


dumb ¼¶¼g©ó¤å³¹

List ±±¨î¶µ¥i§Q¥Îlistindex «ü¥X¥Ø«e¿ï¶µ¦ì¸m¡A½Ð°ÝDblist ¥i¤£¥i¦æ ¦³³oºØ¥\¯à¶Ü?­n¦p¦ó°µ©O?

¦Ñ©Çµª¡G

½Ð¨Ï¥Î
DBList.Text ©M
DBList.SelectItem ¨â­ÓÄÝ©Ê¡A½d¨Ò¦p¤U¡G

'°õ¦æ¥»½d¨Ò½Ð©óªí³æ¥¬¸m Data1,DBList1 ¡A¨Ã¦b DBList1 Äݩʵøµ¡ªº
'RowSource Äæ¦ì¶ñ¤J Data1¡C

Option Explicit

Dim TotalRec As Long
Dim Mark As Variant
Dim Db As Database
Dim Rs As Recordset

Private Sub Data1_Reposition()
    Data1.Caption = Rs.AbsolutePosition + 1 & "/" & TotalRec
End Sub

Private Sub DBList1_Click()
    Debug.Print DBList1.Text
    Rs.Bookmark = DBList1.SelectedItem
End Sub

Private Sub Form_Load()
    Set Db = OpenDatabase("c:\test\mytest.mdb")
    Set Rs = Db.OpenRecordset("student", dbOpenDynaset)

    Rs.MoveLast
    TotalRec = Rs.RecordCount
    Rs.MoveFirst
    Set Data1.Recordset = Rs
    DBList1.ListField = "Name"
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Rs.Close
    Db.Close
End Sub

¦^¯Á¤Þ


¦C¦L DBGrid Cell ùتº¸ê®Æ


§¤¬Ý­·°_¶³´é®É ¼¶¼g©ó¤å³¹

VB¤¤¦p¦ó¦C¦LDBGRIDS¤¤ªº¸ê®Æ?¥Î printer.print ¦ü¥G¬O¤£¤Ó¥i¦æªº,¦³¨ä¥¦ªº¤èªk¶Ü?

¦Ñ©Çµª¡G

¥i¥H¥Î Printer.Print ¨Ó¦C¦L¡A½Ð°Ñ¦Ò¤U¨Ò¡G
Dim I As Long, J As Long
Dim PrintString As String
    For I = 0 To DBGrid1.VisibleRows - 1
        For J = 0 To DBGrid1.Columns.Count - 1
            PrintString = PrintString & DBGrid1.Columns(J).CellText(DBGrid1.RowBookmark(I)) & "/"
        Next
        Printer.Print PrintString
        PrintString = ""
    Next

    Printer.EndDoc

1999/4/3 ¤é­×¥¿¡G

¦b¦¹¦V¦U¦ì©êºp¡A­ì¥»§Ú¥Î DBGrid.Columns(Index).CellText ³o­Ó¤èªk¡A´N¬O¦]¬°¤£§Æ±æ«ü©w Row & Col ·|³y¦¨±²°Ê©ìºC³B²z³t«×¡Aµ²ªG³Ì«áµoı DBGrid ªº RowBuffer ¨Ã¤£¬O¦³¦h¤Ö°O¿ý´N³]¦h¤Ö¦C¡A¦Ó¬O¥u¦³¥iµø½d³òªº¦C¼Æ¸ê®Æ¦Ó¤w¡A·í¥¦±²¨ì¤U¤@­¶®É¡A¤~·|·s Record ©ñ¨ì­ì Buffer ùØ¡C¦]¦¹­n§â°O¿ý±qÀY¦L¨ì§À¡AÁÙ«D±²¤£¥i¡A©Ò¥H§Ú­×¥¿¦p¤U¡A

Option Explicit

Private Sub Command1_Click()
Dim I As Long, J As Long, K As Long
Dim PrintString As String

    For I = 0 To Data1.Recordset.RecordCount - 1
        If K = DBGrid1.VisibleRows Then
            'DBGrid ¤@©w­n±²¨ì¥iµø¤~¯à¨ä RowBuffer ¤~·|¸ü¤J Data ¸ê®Æ
            DBGrid1.Scroll 0, DBGrid1.VisibleRows
            K = 0
        End If
        For J = 0 To DBGrid1.Columns.Count - 1
            'DBGrid1.RowBookmark ¥u¯à§ì¨ì DBGrid ¥iµøªº Record BookMark
            PrintString = PrintString &
DBGrid1.Columns(J).CellText(DBGrid1.RowBookmark(K)) & "/"
        Next
        Printer.Print PrintString
        PrintString = ""
        K = K + 1
        '¥i¥H¨ú®ø¦¹±Ô­z¡A¥[¤W¥u¬OÅý§A¬Ý¨ì¦C¦L¬OÃä±² DBGrid Ãä°õ¦æªº¡C
        DoEvents
    Next
End Sub

Private Sub Form_Activate()
    '¦b°O¿ý¼Æ¶q«Ü¤j®É,¥²¶·§â°O¿ý²¾¨ì³Ì«á¡A§_«h Data1 ¥u·|¶ëº¡ Buffer ªº°O¿ý¦Ó¤w¡C
    Data1.Recordset.MoveLast
    '¥²¶·§â°O¿ý±²¦^¶}©l¡A¥H«K DBGrid ¦C¦L¡C
    Data1.Recordset.MoveFirst
    '­«­n¡A²¾¨ìµ²§À¦A²¾¦^¶}ÀY¡A¬O¬°¤F¸ê®Æ§¹¾ã¨Ã¥B¥¿½T¡C
End Sub

¦^¯Á¤Þ


¦hÄæ¤Î¦h¦C¿ï¨ú


®z¤ô¤T¤d,¥u¨ú¤@¿]¶¼ ¼¶¼g©ó¤å³¹

½Ð°ÝDBGrid¥i¥H°µ¨ìmulti-select¶Ü?

¦Ñ©Çµª¡G

  1. ¦pªG¬O Column ¡A¥i¥Hª½±µ¥Î·Æ¹«©ì¦² multi-select¡C
  2. ¦bµ{¦¡¤¤¥Î SelStartCol ©M SelEndCol °»´ú¨Ï¥ÎªÌ¿ï¨úªº Column¡C
  3. ¦pªG¬O Record ¡A¥²¶·«ö¦í [CTRL] Áä¡A¦A¥Î·Æ¹«¤@­Ó¤@­ÓÂI¨ú¡C
  4. ¦bµ{¦¡¤¤¥Î SelBookMarks  ª«¥ó¥]§t¿ï¨ú¸ê®Æ¦C®ÑÅÒªº¶°¦X¡A¥i¥H¥Î¤U¦C¤è¦¡¨ú¥X¿ï¨ú¦C¸ê®Æ¡G
    Dim I As Integer
        If DBGrid1.SelBookmarks.Count > 0 Then
            For I = 0 To DBGrid1.SelBookmarks.Count - 1
                Debug.Print DBGrid1.Columns(1).CellText(DBGrid1.SelBookmarks.Item(I))
            Next
        End If

¦^¯Á¤Þ


¦A½Í¸ê®Æ®wÄæ¦ì¤¤ Null ­Èªº³B²z


ªü¤ò ¼¶¼g©ó¤å³¹

¦b¼¶¼g¸ê®Æ®wªºµ{¦¡®ÉÄæ¦ìªº­È¸Ó¦p¦ó¨ú±Ë??«ü¦bMicrosoft Access¤¤Äæ¦ì©w¸q®É,¤¹³\Null­È¡B¥²¶·¦³­Èµ¥³]©w¸Ó¦p¦ó¨ú±Ë??

¦Ñ©Çµª¡G

Null ­È¤§©Ò¥H¥²¶·Á׶}¡A¬O¦]¬°¥¦·|³y¦¨¹Bºâ¥¢®Ä¡A¤]´N¬O¥ô¦ó«¬ºAªºÄæ¦ì©MÅܼƻPNull °µ¹Bºâ¡Aµ²ªG³£·|¬O Null¡A¤]¦]¦¹¸òµÛ¥¦¥X¨Óªº Query ©M Recordset ¸ÓÄæ¦ì³£·|¬O Null¡C¦pªG§A¥u¬O³æ¯ÂªºÅã¥Ü¥¦¡A¨ºµ²ªG¬O¤@­ÓªÅ¥Õ¡A·íµM¨SÃö«Y¡A¦ý¦pªG§A°µ¤@¨ÇÄæ¦ìµ²¦X¹Bºâ¡A¨º§t Null ­È­pºâµ²ªG·|§¹¥þ¤£¦P©ó¤£§t Null ­Èªº­pºâµ²ªG¡C¦pªG§A®e³\¤@­ÓÄæ¦ì¦³ Null ­È¡A¨º³Ì«áµ²ªG±N¬O«D§A©Ò¹w´Áªº¡C

©Ò¥H¦b§Ú­Ì­è¾Ç²ß Access ®É¡A©Î³\¤j®a³£¤£¦b¥GÄæ¦ì¦³ Null ­È¡A¦ýÀHµÛ¸ê®Æªí¼W¦h¡A©¼¦¹Ãö«Y¤é¯q½ÆÂø¡AÄæ¦ìºî¦X¹Bºâ·U¨Ó·U¦h¡A¤@­Ó¤¹³\ Null ­ÈªºÄæ¦ì³]©w¡A±N¦¨¬°¤@Áû®IÂ꺦a¹p¡A¥¦·|Åý§Aµ{¦¡¥Rº¡¤£½T©w©Ê¦ÓµLµ·²@ĵ§i¡A¬Æ¦Ü³Ì«á¥²¶·¸Ó¸ê®Æªí¤Î©Ò¦³¬ÛÃöªºQuery¡BForm¡BReport ³£­n­«°µ¡A³o¤]´N¬O Access ³o»òÂû±C¡A¦b§AÄæ¦ì¬° Null ­È®É­n¤@¦A´£¿ô§Aªº­ì¦]¡C

ªü¤ò ¼¶¼g©ó¤å³¹

¦AªÌ¡A¦b¼¶¼g¸ê®Æ®wµ{¦¡®É¡A¨Ï¥ÎªÌ©Ò¿é¤Jªº¸ê®Æ¦s¨ì¸ê®Æ®w¤¤«á¡Aµo²{¥²¶·¦³­ÈªºÄæ¦ì¡F¨Ï¥ÎªÌ¥¼¿é¤J¥ô¦ó­È¡A¦¹®ÉAccess·|µo¥Í¿ù»~¡A¹ï©ó³o¼Ëªº¤@­Ó°ÝÃD¤£ª¾¹D¬O¸Ó¦bµ{¦¡¤¤¥[¤JÀˬd¥²¶·¦³­ÈªºÄæ¦ì¬O§_¤w¿é¤Jªº§PÂ_¡HÁÙ¬O³æ¾a¥H¸ê®Æ®wµo¥Í¿ù»~«á¦A¥h°µ®·®»¸ê®Æ®wªº¿ù»~ªº°T®§¤§«á¦A¤ÏÀ³µ¹¨Ï¥ÎªÌ??

¦Ñ©Çµª¡G

§A¤£À³¸Ó§â³o°T®§§iª¾¨Ï¥ÎªÌ¡A¦]¬°¥L¨Sªk²z¸Ñ(¤]¨S³d¥ô²z¸Ñ) Null ­È¹ï¸ê®Æ®wí©w¹B§@ªº¶Ë®`¡A¥L¥u¬O·Q¡y§Ú¥ý¶°¤¤¿é¤J¦¹¸ê®Æ®wªº³o³¡¥÷Äæ¦ì¡A«Ý·|§Ú¦A¿é¤J¨º¤@³¡¥÷Äæ¦ì¡C¡z·í§A­­¨î¥L³o¶µ¦Û¥Ñ®É¡A§A»{¬°¥L·|«ç¼Ëµû»ù§A³]­pªºµ{¦¡¡H

¦Ü©ó¨Æ¥ý¦bµ{¦¡¤¤¥[¤JÀˬd¡A¦n¤@ÂI¡A¦ýÁÙ¤£¬O«Ü¦n¡A¦]¬°§AÁÙ¬O­­¨î¤F¥Lªº¨Ï¥Î¦Û¥Ñ¡C©Ò¥H§Ú»{¬°³Ì¦nªº¤è¦¡¬O§Q¥Î Field.DefauldValue ªº³]©w¡A©Î¬O¦b Append °Ê§@®É¡A¦pªG¨Ï¥ÎªÌ¥¼¿é¤J«h©ñ¨Çªì©l­È¶i¤J¥²¶·¦³­ÈªºÄæ¦ìùØ¡AÅý¨Ï¥ÎªÌ¨É¦³ÁöµM¯Ê¤F¨ÇÄæ¦ì¸ê®Æ¡A¦ý¤´¥i¦³·s¼W°O¿ýªºÅv§Q¡A¦Ü©ó DefaultVale ¬O­n´X­ÓªÅ¥Õ¦r¤¸©Î¨ä¥L­È¡A´N¬Ý§A¤é«á¥´ºâ«ç»ò¦A§Q¥Î³o¨ÇÄæ¦ì¤F¡C

¨ä¹ê³Ì«á³o­Ó°ÝÃD·|¦^¨ìµ{¦¡³]­p®v¨}¤ß³o»ò­Ó°ò¥»ªº¤H©Ê°ÝÃD¤W¡Aªº½T¡A¦ó¥²§âÄæ¦ì³]¦¨¥²¶·¦³­È³o»ò¨¯­W¡H°®¯Ü³q³q¤¹³\ Null ­È¡A§A³]­pªº»´ÃP¡A¨Ï¥ÎªÌ¥Îªº¦Û¥Ñ¡A¤Ï¥¿¥u­n§Ú´£¨Ñªº¥\¯à¨S°ÝÃD¡A½Ö¤SºÞ±o¤F¥H«á³o¨Ç¸ê®Æ¦A§Q¥Î©Ê¦p¦ó¡A¬Æ¦Ü±N¨Ó¦A§Q¥Î·d±oµJÀYÄêÃB¡A¨º¤]¬O¤U­Ó±µ®×ªº­Ë¾`°­ªº¨Æ¡A¤j®a¬Æ¦ÜÁÙ·|Ãh©À§A¡A»¡§A³]­p®É³£¨S°ÝÃD¡A´«­Ó¤H´N°ÝÃD¤@°ï¡C

¦ý¦pªG§AÁÙ¦³¤@¨Ç±M·~ªº¤£¦w»P¤£§Ô¡A¨º§A§K¤£¤F­n¬°¤F±N¨Óªºµo®i¦Ó­­¨î²{¦b¨Ï¥ÎªÌªº¦Û¥Ñ¡A¤S­n¬°«ç¼Ë´î¤Ö³o¨Ç­­¨î±a¨Óªº¤£«K¦Ó«õªÅ¤ß«ä¡A¦h¼g¤@°ïµ{¦¡½X¡CÁa¨Ï§A¦p¦¹­W¤ßºÜ¼{¡A«o¥¼¥²¯à±o¦Ñª©©Î·~¥Dªº»{¦P¡A¦]¬°§A¶}µoªº®É¶¡¤ñ¤Hªø¡A§A¼gªºµ{¦¡¤ñ¤H®aÅo¶Û¡C©Ò¥H¡A¬Ý§A¦Û¤v§a¡A¦Ñ©Ç¬ÝªºÀ´µ{¦¡¡A«o¥¼¥²¬ÝÀ´¤H¥Í¡A¸Ó°µ­Ó«ç¼Ëªºµ{¦¡³]­p®v¡A¥u¦³§A¦Û¤v¯à¨M©w¤F¡C

¦^¯Á¤Þ


¦p¦óÁÙ­ì¤é´ÁÄæ¦ì¬°¥¼¿é¤J«¬ºA


±H¥óªÌ: chiu

¦b¤@form¤¤¡A«Ø¥ß¤@­Ótextbox¡A¦ý¦¹textboxªº¤º®e¬°access¸ê®Æ®w¤§¤é´Á«¬ºAÄæ¦ì¡A¤µ¤Ñ­Y§Ú¹ïtextbox¿é¤J¸ê®Æ«á¡Aµo²{¿é¿ù¤é´Á¦Ó­n±Ntextbox¤º®eÅܦ¨ªÅ¥Õ(null)¬O§_¦³¿ìªk¿ì¨ì¡H

¦Ñ©Çµª¡G

¦³¿ìªk¡A¥Î Recordset!FieldName.Value=Null ªº±Ô­z¡A»yªk¦p¤U¡G
Private Sub Data1_Validate(Action As Integer, Save As Integer)
    If TextBox.Text = "" Then
        Data1.Recordset.Edit
        Data1.Recordset!FieldName = Null
        Data1.Recordset.Update
    End If
End Sub

¦^¯Á¤Þ


¬°¸ê®Æ°O¿ý°µ¸s²Õ¤À¶µ²Î­p


Ä«ªG¿} ¼¶¼g©ó¤å³¹

§Úªº¸ê®Æ®w¥ÎSQL¡A¨ä¤¤¤@­Ótable¥sºû­×ÀÉ,¦³¤@­ÓÄæ¦ì¥s"¦A«×¥s­×­ì¦]"(­ì¦]¦³¥|­Ó,¬O¥Îoption¿ï¨úªº)¡A>¦pªG­n°µ¦¨³øªí,¸Ó¦p¦ó²Î­p¨C­Ó­ì¦]ªº¦¸¼Æ¥Î³øªíÅã¥Ü¥X¨Ó¡H

¦Ñ©Çµª¡G

SQLString="SELECT ¦A«×¥s­×­ì¦], Count(¦A«×¥s­×­ì¦]) AS ¥s­×¦¨¦]¦X­p " & _
"FROM table_ºû­×ÀÉ " & _
"GROUP BY ¦A«×¥s­×­ì¦]"

¦^¯Á¤Þ


¶}±Ò¸ê®Æ®w¤¤¥ô¤@¸ê®Æªí


±H¥óªÌ: sillen

½Ð°Ý¥i¤£¥i¥H¦b§â¤@­ÓMDB¸ê®Æ®w¤¤ªº¸ê®ÆªíÅã¥Ü¦b¤@­ÓLIST¤¸¥ó¤¤©O?¦]¬°§Ú§Ë¤F¤@­Ócommand dialog ªº¤¸¥ó¨Ó¿ï¨úMDBªº¸ê®Æ®w¡A¥i¬O¤£ª¾¦p¦ó¦A¿ï¨úMDB¸ê®Æ®w¤¤ªº¸ê®Æªí..... ?

¦Ñ©Çµª¡G

'´ú¸Õ¥»µ{¦¡½Ð©óªí³æ¥¬¸m Data1,DBGrid1,CommonDialog1,List1
Option Explicit

Dim Db As Database
Dim Rs As Recordset

Private Sub Form_Load()
Dim Tb As TableDef
CommonDialog1.filename = ""
CommonDialog1.ShowOpen
If CommonDialog1.filename <> "" Then
Set Db = OpenDatabase(CommonDialog1.filename)
For Each Tb In Db.TableDefs
'Tabledef.Attributes ÄݩʬO°O¸ü¦U¸ê®Æªí¯S©Êªº¤@­ÓÄÝ©Ê¡A¨ä¤¤ dbSystemObject ªí¥Ü
'¸Ó¸ê®Æ¬° MDB ¨t²Î¸ê®Æªí¤£¥i¥Ñ¨Ï¥ÎªÌ¶}±Ò­×§ï¡C
If Not Db.TableDefs(i).Attributes And dbSystemObject Then
List1.AddItem Tb.Name
End If
Next
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Rs.Close
Db.Close
End Sub

Private Sub List1_Click()
Set Rs = Db.OpenRecordset(List1.List(List1.ListIndex))
Set Data1.Recordset = Rs
End Sub

¦^¯Á¤Þ


¥Î ComBo ¾Þ§@¨â­ÓÄæ¦ì°O¿ý


±H¥óªÌ: Jimmy Cheng

­Y Table1 ¬°«È¤áÀÉ¡A¦³·~°È­û©m¦W¤Î·~°È­û¥N¸¹¨âÄæ¦ì¡A½Ð°Ý¦p¦ó¦b Combo ¤¤ÂI¿ï·~°È­û©m¦W¦Ó±oª¾·~°È­û¥N¸¹¡H

¦Ñ©Çµª¡G

¦b¦V Combo ¼W¥[·~°È­û©m¦W®É¡A§Y§Q¥Î Combo.ItemData Äݩʧâ·~°È¥N¸¹¥[¶i¥h¡A¤~¯à¦b Combo_Click ®É¡Aª½±µÅª¨ú·~°È­û¥N¸¹¡A¦Ó¤£»Ý¦A Seek ¤@¦¸¡C

  1. .§â¸ê®Æ¥[¨ì Combo:
    Recordset.MoveFirst
    Do While Not Recordset.Eof
        combo.AddNew Recordset!·~°È©m¦W
        combo.ItemData(combo.NewIndex)=Recordset!·~°È¥N¸¹
    Loop
  2. ¨ú¥X·~°È¥N¸¹:
    Private Sub Combo_Click
    dim var·~°È¥N¸¹ As Long

            var·~°È¥N¸¹=combo.ItemData(combo.ListIndex)
    End Sub

¦^¯Á¤Þ


±N³s±µªººô¸ô¸ê®Æªí¦s¤J¥»¾÷¸ê®Æ®w


±H¥óªÌ: Dino

½Ð±Ð¦p¦ó±N SQL ¸ê®Æ®w¤º®eÂনACCESSªº.mdbÀÉ¡H

¦Ñ©Çµª¡G

  1. ½Ð¨Ì¦Û¤vªººô¸ôª¬ªp¡A¥Î¤@ Table ³s±µºô¸ô¸ê®Æ®w¡C
  2. ³s±µ¤W«á¥Î SQL ªº²£¥Í¸ê®Æªí¬d¸ß¡ASELECT INTO ±Ô­z§âºô¸ô¸ê®Æªí·s¼W¤@¥÷¨ì Access ¸ê®Æ®w¨Ó¡Aµ{¦¡½X¦p¤U¡G
    Option Explicit

    Dim Db As Database
    Dim Qd As QueryDef
    Private Sub Command1_Click()
        Set Db = OpenDatabase("§Aªº¥»¾÷¸ê®Æ®w.mdb")
        Set Qd = Db.CreateQueryDef("²£¥Í¬d¸ßªº¦WºÙ/§A¥iÀH«K¨ú¤@­Ó")
        Qd.SQL = "SELECT * INTO ¥»¾÷¸ê®Æªí FROM ºô¸ô¸ê®Æªí;"
        Qd.Execute
        Db.QueryDefs.Delete "²£¥Í¬d¸ßªº¦WºÙ"
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
        Qd.Close
        Db.Close
    End Sub

¦^¯Á¤Þ


¦b SQL ¦r¦ê¤¤´¡¤J ['] ¦r¤¸


­Û­Û~½Ö®³§Úªº¥úºÐ:(~) ¼¶¼g©ó¤å³¹

½Ð°Ý SQLªº¦r¦ê¬O¥Î³æ¤Þ¸¹' ®Ø°_¨Óªº¡A¦ý¦pªG§Ú­n¿é¤J¬Y¤@¦r¦ê,¨ä¤¤¥]§t¤F³æ¤Þ¸¹ [']¡A¦p¦¹...¦r¦ê¤¤ªº ['] ´N·|³y¦¨¿ù»~...¡A¦³¨S¦³¤°»ò¸Ñ¨M¿ìªk??

¦Ñ©Çµª¡G

¥i¥H¥Î Chr() ¨ç¼Æ°t¦X Ascii ¦r½X¸Ñ¨M¡A
"It" & Chr(39) & "s not difficult"

¦^¯Á¤Þ


¦^­º­¶

1