InterviewSolution
| 1. |
Solve : Visual Basic-Data Report generation through querry? |
|
Answer» Sir, dim dd1,dd2 as string this declares two variables- dd1 will be a Variant (or boxed object in .NET)- dd2 will be a String. Quote dd1=text1.textthis was original placed on one line in your post but I assume it was supposed to be two. this assigns the string contents of both dd1 and dd2 to the respective contents of the textboxes. remember however that dd1 is NOT a string variable, but rather a "Variant" type (or a boxed object type for .NET)... in either case, it is being set to a string. Quote dataenvironment.command1(dd1,dd2) if this is VB6, this line won't work at all unless you remove the parentheses.... so I imagine this is .NET (again, not a lot to go on here). the two expected parameters are double- the given parameters are Variant (or boxed object) and String. the fix is to use Date variables rather then string variables to represent the input in the textboxes, using "DateValue" to convert the contents of the textbox to the date variable. Sir, THANKS for your quick response. I am sending my project on VB-6 as a whole in a zip file and i tried my problem once again keeping a side date criteria and took simply percentage of marks but could not succeded to generate Microsoft data report while single criteria is FURNISHING the desired Data Report. when I wrote code for single criteria, it generated report properly but when I applied criteria to know the students for a range of marks through two text boxes, it could not process report flashing error message either Syntax error or argument may not be optional while system itself says ( Param1 as double, Param2 as double) where is mistake here ? This is VB-6 application, (Data Environment and Data Report) [attachment deleted by admin]original code: Code: [Select]Private Sub Command1_Click() 'IN SQL STATEMENT FOLLOWING HAS BEEN WRITTEN 'SELECT CLASS.NAME, CLASS.DOB, CLASS.MARKS1 FROM CLASS WHERE (CLASS.MARKS1 > ?) ORDER BY NAME Dim XC1 As Long Dim XX1 As String XX1 = (Trim(Text1.Text)) XC1 = Val(XX1) '*********issue 1******** DataEnvironment1.Command1 (XC1) DataReport1.Show End Sub Private Sub Command2_Click() ' FOR RANGE OF MARKS Dim XC1 As Long Dim XC2 As Long Dim XX1 As String Dim XX2 As String XX1 = (Trim(Text1.Text)) XC1 = Val(XX1) XX2 = (Trim(Text2.Text)) XC2 = Val(XX2) 'DataEnvironment1.Command1.param1 = (XC1) ' argument not optional 'DataEnvironment1.Command1.param2 = (XC2) 'ISSUE TWO DataEnvironment1.Command1(XC1, XC2) ' Syntax error DataReport1.Show End Sub Code: [Select]Private Sub Command1_Click() 'IN SQL STATEMENT FOLLOWING HAS BEEN WRITTEN 'SELECT CLASS.NAME, CLASS.DOB, CLASS.MARKS1 FROM CLASS WHERE (CLASS.MARKS1 > ?) ORDER BY NAME Dim XX1 As Date XX1 = DateValue(Text1.Text) DataEnvironment1.Command1 XX1,XX1 DataReport1.Show End Sub Private Sub Command2_Click() ' FOR RANGE OF MARKS Dim XX1 As Date Dim XX2 As Date XX1 = DateValue(text1.text) XX2 = DateValue(text2.text) DataEnvironment1.Command1 XX1, XX2 DataReport1.Show End Sub Issue one- is fairly obvious. argument not optional. because it requires two arguments, and then executes the query: Code: [Select]SELECT CLASS.NAME, CLASS.DOB, CLASS.MARKS1 FROM CLASS WHERE (CLASS.MARKS1 BETWEEN ? AND ?) ORDER BY NAME where the two question marks correspond to the passed parameters. The obvious solution is the pass the same ITEM for both parameters. issue two: (syntax error) this one is simple. remove the parentheses. Also- changed the data types from string to Date. |
|