:1008-1402(2005)03-0381-07VB+SQL1,2,2(1.,100083;2.,154007):VB+SQL,,ADOCommand;,.:VisualBasic;SQLServer;;:TP311.13:A0,,,.VisualBasic,ADOCommand.CommandCommandText,?,:SELECT3FROMWHERELIKE??,.CommandParameters,.,Com2mand,ADO.CommandCreateParameter,,CommandAppendParatemeter.,,.11.1,,,,,,,,,.1,:(1)VisualBasic6,FoodOutIn2fQuery,9TextBox,,,,,,,,,.(2)9Label,,,,,,,,,.(3)CommandButton,,Frame1,.:2005-03-28:(1977),,,.233()Vol.23No.3200507JournalofJiamusiUniversity(NaturalScienceEdition)July2005(4)P,,MicrosoftDataGridControls6.0(OLEDB),.DataGrid,.1(5)1.(6)1.1AutoSizeCaptionForm1Frame1Label1TrueLable2,Lable3,Lable4,Lable5,Lable6,Lable7,Lable8,AutoSize,CaptionLabel9TrueNameCaptionText1Text1NameText2,Text3,Text4,Text5,Text6,Text7,Text8,NameText9Text7InSpotCommand1CmdQueryCommand2CmdExitDataGrid11.2Connection,Command,,,.:(1):ConnectionCommand,FormLoad.ConnectionCommand:ConnectionCommandDimobjCnAsConnection,objCmdAsCommand(2)FormLoad,Connection,Command,FormLoad:PrivateSubFormLoad()SetobjCn=NewConnectionConnectionobjCnWithobjCn.Provider=SQLOLEDB.ConnectionString=UserID=sa;PWD=;DataSource=(local);&InitialCatalog=283()2005.OpenEndWithCommandobjCmdSetobjCmd=NewCommandSetobjCmd.ActiveConnection=objCnWithobjCmd.CommandText=SELECT3FROMWHERELIKE?&ANDLIKE?&ANDLIKE?.CommandType=adCmdTextEndWithCommandobjCmdDimParmAsNewParameterSetParm=objCmd.CreateParameter(,adVarChar,adParamInput,6)objCmd.Parameters.AppendParmSetParm=objCmd.CreateParameter(,adVarChar,adParamInput,16)objCmd.Parameters.AppendParmEndSub(3),,,.Command,.,,:PrivateSubcmdQueryClick()DimobjRsAsRecordset,objSourceAsRecordsetobjCmd()=%&Text1Name&%objCmd()=%&Text29Date&%objCmd()=%&Text7InSpot&%SetobjRs=objCmd.Execute(),SetobjSource=NewRecordsetRecordsetFori=0ToobjRs.Fields.Count-1objSource.Fields.AppendobjRs.Fields(i).Name,adVarChar,objRs.Fields(i).DefinedSizeNextobjSource.OpenRecordsetWhileNotobjRs.EOFobjRsobjDataSourceobjSource.AddNewobjSource!=objRs!3833,:VB+SQLobjSource!=objRs!objSource!=objRs!objRs.MoveNextWendIfobjSource.RecordCount0ThenobjSource.MoveFirstobjDataSourceSetDataGrid1.DataSource=objSourceDataGrid1.Caption=&objSource.RecordCount&!EndSub(4),,:PrivateSubForm-Unload(CancelAsInteger)CommandConnectionSetobjCmd=NothingSetobjCn=NothingEndSub(5)122.12(1)FoodInOutDataCon,SalesDate,CommandType1,CommandTextselectdistictfrom,.(2)SalesDate,,,Command1,SQL,selectdistinctfrom,,,,,,,,.SalesDateCommand1.[1]483()2005(3)DataConSalesData,,dbo.,.2.2(1)SalesDateReport,NameSalesDateReport,Caption,DataSourceFoodInOut,DataMemberSalesDateDataMember.(2).22.3(1),3.3(2)2.2Form1CaptionNameSalesDateReportCommand1CaptionNameCmdOKLabl1AutoSizeCaptionTrueCommand2CaptionNameCmdShowNameAllowUpDateDataGrid1FalseCommand3CaptionNameCmdExitDataGrid1allowAddNewDataSourceDataMemberFalseFoodInOutSalesDataComboBoxNameTextCmbDate(3).,,,:PrivateSubFormLoad()Dimi%WithFoodInOut.rsSalesDataIf.State=adStateClosedThen.OpenIf.RecordCount0Then.MoveFirstWhileNot.EOFFori=0TocmbDate.ListCount-1IfcmbDate.List(i)=Left(.Fields(),14)ThenExitForNextIfi=cmbDate.ListCountThencmbDate.AddItemLeft(.Fields(),14)5833,:VB+SQLEndIf.MoveNextWendEndIfEndWithEndSub(4).,[2],:PrivateSubcmdOkClick()IfTrim(cmbDate)ThenFoodInOut.rsSalesData.Filter==&cmbDate&FoodInOut.rsSalesDate.Filter==&cmbDate&ElseFoodInOut.rsSalesData.Filter=FoodInOut.rsSalesDate.Filter=SetDataGrid1.DataSource=FoodInOutDataGrid1.DataMember=SalesDataEndIfEndSub(5),,:PrivateSubcmdShowClick()FoodOutDateReport.ShowFoodOutDateReport.SetFocusEndSub(6),:PrivateSubFormResize()DataGrid1.Width=Me.ScaleWidth-DataGrid1.Left-200DataGrid1.Height=Me.ScaleHeight-DataGrid1.Top-400EndSub(7),,:PrivateSubcmdExitClick()UnloadMeEndSub(8)4.(9).3,,VisualBasic,ADOCommand.CommandCommandText,?,:SELECT3FROMWHERELIKE?683()2005CommandParameters,.,Command,ADO.CommandCreateParameter,,CommandAppendParatemeter.,,.,,.4:[1],.VisualBasic6.0[M].:,2004.[2],.VisualFoxPro6.0[M].:,2002.RealizingQuickParameterInquireandReportFormswithVBandSQLFANGXiu-nan1,TANGFeng-xiang2,LUTong-fu2(1.BeijingSpaceflightUniversity,Beijing100083,China;2.JiamusiUniversity,Jiamusi154007,China)Abstract:InthisPaper,themeansofquickparameterofinquireandreportformswithVB+SQLareintro2ducedthroughanexample.UsingADOcommandobjecttocreateparameterofinquireisstudied.Themethodstopro2duceparameterreportformsaregiven.Keywords:VisualBasic;SQLServer;quickparameterreportforms;quickparameterinquire7833,:VB+SQL