# Re: SQL的笨问题

Posted by Steve TSE on August 24, 1998 at 12:42:09:

In Reply to: SQL的笨问题 posted by yeong huann on August 23, 1998 at 02:29:10:

: 请问在VB中如何能不用透过QueryDef物件而能直接使用SQL的程式码,又此时资料表的属性该如何设定?
: 谢谢!!

You can use data control's RECORDSOURCE property or OpenRecordset with SQL statement to do it.
For example,
strSQL = "SELECT * FROM Publisher " & _
"WHERE PublishID = '" & Text1.text & "'"
datDataCtl.RecordSource = strSQL
datDataCtl.Refresh

Dim rst as Recordset
rst = gdbCurrentDB.OpenRecordset(strSQL, _ dbOpenDynaset)

Follow Ups: