Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Power Basic

Страница: 1 |

 

  Вопрос: запрос SQL Добавлено: 13.05.10 18:10  

Автор вопроса:  Дмит | Web-сайт: dimit.pochta.ru
Пытаюсь сделать запрос к БД через ADO:
"SELECT * FROM SLTab WHERE Name Like '*мед'"
не находит :(
"SELECT * FROM SLTab WHERE Name LIKE 'Архимед'"
находит
т.е. не могу использовать LIKE.

Как выкрутится? посоветуйте :)
или хоть куда копать?

Пользуюсь примером:
#COMPILE EXE
#DIM ALL
#INCLUDE "ADO.inc"
#INCLUDE "WIN32API.INC"
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
GLOBAL hDlg  AS DWORD
GLOBAL LS() AS STRING
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
%frmMain             =  101
%IDC_BUTTON          = 1001
%IDC_LISTBOX         = 1005
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
DECLARE CALLBACK FUNCTION ShowfrmMainProc()
DECLARE FUNCTION ShowfrmMain(BYVAL hParent AS DWORD) AS LONG
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
SUB GetAccessData()
LOCAL dbConn AS VARIANT
LOCAL rsSet AS VARIANT
LOCAL rsProducts AS ADODBRecordset
LOCAL rsFields AS ADODBFields
LOCAL rsField AS ADODBField
LOCAL vFields AS VARIANT
LOCAL vField AS VARIANT
LOCAL bEOF AS VARIANT
LOCAL lngColumn AS VARIANT
LOCAL vOut AS VARIANT
LOCAL lRes AS LONG
LOCAL strFieldValue AS STRING
LOCAL i AS LONG

    'Make a database connection (application path)
    SetDBconnection "Provider=microsoft.jet.OLEDB.4.0;Data Source='C:\Documents and Settings\Kompress\Мои документы\Заготовки\СловарьV\СловарьV.mdb'", %adUseClient, dbConn
    'Get the recordset
    GetRecordSetObj dbConn, "SELECT * FROM SLTab", %adUseClient, rsSet
    SET rsProducts = rsSet 'Load the ADODBRecordset object
    OBJECT CALL rsProducts.MoveFirst 'Goto the first record
    DO
        OBJECT GET rsProducts.EOF TO bEOF 'Get the end of file value
        IF ISTRUE VARIANT#(bEOF) OR i > 1000 THEN EXIT DO

        OBJECT GET rsProducts.Fields TO vFields 'Get the specific row fields
        SET rsFields = vFields

        lngColumn = 0 'Column number
        OBJECT GET rsFields.Item(lngColumn) TO vField 'Get column field
        SET rsField = vField
        OBJECT GET rsField.Value TO vOut 'Get field value /in this case a string/
        strFieldValue = VARIANT$(vOut)

 REDIM PRESERVE LS(i) AS STRING
        LS(i)=strFieldValue
        i = i + 1
      CONTROL SEND hDlg, %IDC_LISTBOX, %LB_ADDSTRING, 0, STRPTR(strFieldValue), TO lRes 'set text in list
        OBJECT CALL rsProducts.MoveNext 'Goto the next record
    LOOP
    'CONTROL ADD LISTBOX, hDlg, %IDC_LISTBOX, LS(), 3, 3, 168, 135
    ' MSGBOX  LS(0)
    SET rsField = NOTHING
    SET rsFields = NOTHING
    SET rsProducts = NOTHING
    CloseDBconnection dbConn 'Close the database

END SUB
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
FUNCTION PBMAIN()
  ShowfrmMain %HWND_DESKTOP
END FUNCTION
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
CALLBACK FUNCTION ShowfrmMainProc()

  SELECT CASE AS LONG CBMSG
    CASE %WM_INITDIALOG
    CASE %WM_NCACTIVATE
      STATIC hWndSaveFocus AS DWORD
      IF ISFALSE CBWPARAM THEN
        ' Save control focus
        hWndSaveFocus = GetFocus()
      ELSEIF hWndSaveFocus THEN
        ' Restore control focus
        SetFocus(hWndSaveFocus)
        hWndSaveFocus = 0
      END IF

    CASE %WM_COMMAND
      ' Process control notifications
      SELECT CASE AS LONG CBCTL
        CASE %IDC_BUTTON
          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
            GetAccessData

          END IF
      END SELECT
  END SELECT
END FUNCTION
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
FUNCTION ShowfrmMain(BYVAL hParent AS DWORD) AS LONG
  LOCAL lRslt AS LONG

  DIALOG NEW  hParent, "ADO example", 70, 70, 173, 164, %WS_POPUP OR _
    %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR _
    %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
    %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_WINDOWEDGE OR _
    %WS_EX_CONTROLPARENT OR %WS_EX_TOPMOST OR %WS_EX_LEFT OR _
    %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
  CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON, "Get Data", 63, 141, 108, 21
  CONTROL ADD LISTBOX, hDlg, %IDC_LISTBOX, , 3, 3, 168, 135, %WS_CHILD OR _
    %WS_VISIBLE OR %WS_TABSTOP OR %WS_HSCROLL OR %WS_VSCROLL OR _
    %LBS_STANDARD OR %LBS_SORT OR %LBS_NOTIFY, %WS_EX_CLIENTEDGE OR _
    %WS_EX_STATICEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
    %WS_EX_RIGHTSCROLLBAR

  DIALOG SHOW MODAL hDlg, CALL ShowfrmMainProc TO lRslt

  FUNCTION = lRslt
END FUNCTION
'------------------------------------------------------------------------------

Ответить

  Ответы Всего ответов: 2  

Номер ответа: 1
Автор ответа:
 Skywalker



ICQ: 300-70-6пятьЪ 

Вопросов: 62
Ответов: 545
 Web-сайт: iSkywalker.ru
 Профиль | | #1
Добавлено: 13.05.10 21:13
не * а %

Ответить

Номер ответа: 2
Автор ответа:
 Дмит



Вопросов: 11
Ответов: 160
 Web-сайт: dimit.pochta.ru
 Профиль | | #2
Добавлено: 16.09.10 18:43
Спасибо получилось :)

Ответить

Страница: 1 |

Поиск по форуму





© Copyright 2002-2011 VBNet.RU | Пишите нам