Last post Nov 01, 2014 06:57 PM by jeffwood
Member
13 Points
84 Posts
Oct 16, 2014 02:31 PM|jeffwood|LINK
Dear Forum I am trying to make it so users can select more than one checkbox and search a table for all the selected options. Any idea where I am going wrong on this?
Thank you for your help. I totally appreciate it.
Jeff Here is the error I am getting:
Compiler Error Message: BC30516: Overload resolution failed because no accessible 'Substring' accepts this number of arguments. Source Error:
Line 77: Line 78: If chkboxes.length = 1 Then Line 79: inStatement= inStatement.Substring Line 80: end if Line 81: Instatement = instatement &')'
Here is my main code:
Dim chkboxes (5) As Integer
If bedroom1.checked = true chkboxes (0)=1 end if
If bedroom2.checked=true chkboxes (1)=2 end if
Dim inStatement As String inStatement = "("
For i As Integer = 1 To 100
If chkboxes(i)<>0 Then
'If chkboxes (i) Is Not Nothing Then inStatement = inStatement & chkboxes (i) end if Next
If chkboxes.length = 1 Then inStatement= inStatement.Substring end if instatement = instatement &')' Next;
Substring (0. instatement length -1)
The part of the code that queries the database: dim SqlCmd as new StringBuilder() SqlCmd.Append("SELECT * FROM plans WHERE Planname LIKE '" & Plannametext & "' AND Sqrft >= '" & Sqrftminint & "' AND Sqrft <= '" & Sqrftmaxint & "' AND Wide <= '" & Wideint & "' AND Deep <= '" & Deepint & "' AND Bedrooms in ('2','4')' AND Floors = '" & Floorsint & "' AND Garages >= '" & Garagesminint & "' AND Garages <= '" & Garagesmaxint & "' AND Alleyfront = '" & Alleyfrontint & "' AND Baths >= '" & Bathstext & "' ")
All-Star
101931 Points
20703 Posts
Oct 17, 2014 03:27 AM|MetalAsp.Net|LINK
String.SubString() expects at least one parameter: http://msdn.microsoft.com/en-us/library/system.string.substring(v=vs.110).aspx
16806 Points
2777 Posts
Oct 17, 2014 03:54 AM|Kevin Shen - MSFT|LINK
Hi jeffwood,
The issue that you didn't set a parameter to the Substring method.
You need to use it like below:
string a="xxxxxxx"; string s=a.SubString(2);
Here is a working demo for you:
http://msdn.microsoft.com/en-us/library/hxthx5h6(v=vs.110).aspx
Best Regards,
Kevin Shen.
Nov 01, 2014 06:57 PM|jeffwood|LINK
Thanks for your help.
Here is the adjusted code that we came up with that makes it work:
If bedroom3.checked = true chkboxes (2)=3 end if
If bedroom4.checked=true chkboxes (3)=4 end if
If bedroom5.checked=true chkboxes (4)=5 end if
For i as integer =0 to chkboxes.length -1
inStatement = inStatement & chkboxes (i) & "," end if Next
If chkboxes.length = 1 Then inStatement= inStatement.Substring(0) end if
inStatement = inStatement.Substring (0, instatement.Length -1)
inStatement = inStatement & ")"
Member
13 Points
84 Posts
Getting error: Overload resolution failed because no accessible 'Substring' accepts this number o...
Oct 16, 2014 02:31 PM|jeffwood|LINK
Dear Forum
I am trying to make it so users can select more than one checkbox and search a table for all the selected options.
Any idea where I am going wrong on this?
Thank you for your help. I totally appreciate it.
Jeff
Here is the error I am getting:
Compiler Error Message: BC30516: Overload resolution failed because no accessible 'Substring' accepts this number of arguments.
Source Error:
Line 77: Line 78: If chkboxes.length = 1 Then Line 79: inStatement= inStatement.Substring Line 80: end if Line 81: Instatement = instatement &')'
Here is my main code:
Dim chkboxes (5) As Integer
If bedroom1.checked = true
chkboxes (0)=1
end if
If bedroom2.checked=true
chkboxes (1)=2
end if
Dim inStatement As String
inStatement = "("
For i As Integer = 1 To 100
If chkboxes(i)<>0 Then
'If chkboxes (i) Is Not Nothing Then
inStatement = inStatement & chkboxes (i)
end if
Next
If chkboxes.length = 1 Then
inStatement= inStatement.Substring
end if
instatement = instatement &')'
Next;
Substring (0. instatement length -1)
The part of the code that queries the database:
dim SqlCmd as new StringBuilder() SqlCmd.Append("SELECT * FROM plans WHERE Planname LIKE '" & Plannametext & "' AND Sqrft >= '" & Sqrftminint & "' AND Sqrft <= '" & Sqrftmaxint & "' AND Wide <= '" & Wideint & "' AND Deep <= '" & Deepint & "' AND Bedrooms in ('2','4')' AND Floors = '" & Floorsint & "' AND Garages >= '" & Garagesminint & "' AND Garages <= '" & Garagesmaxint & "' AND Alleyfront = '" & Alleyfrontint & "' AND Baths >= '" & Bathstext & "' ")
All-Star
101931 Points
20703 Posts
Re: Getting error: Overload resolution failed because no accessible 'Substring' accepts this numb...
Oct 17, 2014 03:27 AM|MetalAsp.Net|LINK
String.SubString() expects at least one parameter: http://msdn.microsoft.com/en-us/library/system.string.substring(v=vs.110).aspx
All-Star
16806 Points
2777 Posts
Re: Getting error: Overload resolution failed because no accessible 'Substring' accepts this numb...
Oct 17, 2014 03:54 AM|Kevin Shen - MSFT|LINK
Hi jeffwood,
The issue that you didn't set a parameter to the Substring method.
You need to use it like below:
Here is a working demo for you:
http://msdn.microsoft.com/en-us/library/hxthx5h6(v=vs.110).aspx
Best Regards,
Kevin Shen.
Member
13 Points
84 Posts
Re: Getting error: Overload resolution failed because no accessible 'Substring' accepts this numb...
Nov 01, 2014 06:57 PM|jeffwood|LINK
Thanks for your help.
Here is the adjusted code that we came up with that makes it work:
Dim chkboxes (5) As Integer
If bedroom1.checked = true chkboxes (0)=1 end if
If bedroom2.checked=true chkboxes (1)=2 end if
If bedroom3.checked = true chkboxes (2)=3 end if
If bedroom4.checked=true chkboxes (3)=4 end if
If bedroom5.checked=true chkboxes (4)=5 end if
Dim inStatement As String inStatement = "("
For i as integer =0 to chkboxes.length -1
If chkboxes(i)<>0 Then
inStatement = inStatement & chkboxes (i) & "," end if Next
If chkboxes.length = 1 Then inStatement= inStatement.Substring(0) end if
inStatement = inStatement.Substring (0, instatement.Length -1)
inStatement = inStatement & ")"