I am running a SQL Stored Procedure that will give the
user a count of how many records are in the database as
per certain criteria.
I'm using the Execute Scalar Method.
I have no problem passing values that the user inputs
into Text boxes to my Stored Procedure. However I have a
drop down list with a listing of the individual States,
which the user selects. I am trying to use the
SelectedValue of the drop down list but I am getting a
message that SelectedValue is not a member of the
parameter collection. Would anybody know how to pass that
parameter to the Stored procedure. Below is a piece of
the program to look at. Thanks for any help that can be
provided.
Sub GetCount
Dim MyConnection As SqlConnection
MyConnection = New SqlConnection("server='(local)'; user
id='sa'; password='fritz'; database='Cutis'")
Dim testCMD As SqlCommand = New SqlCommand ("EMSCOUNTER",
MyConnection)
testCMD.CommandType = CommandType.StoredProcedure
Dim Last As SqlParameter = testCMD.Parameters.Add
("@Last", SqlDbType.VarChar, 6)
Last.Value = TxtLast.Text
Dim First As SqlParameter = testCMD.Parameters.Add
("@First", SqlDbType.VarChar, 1)
First.Value = TxtFirst.Text
Dim Subscr As SqlParameter = testCMD.Parameters.Add
("@Subscr", SqlDbType.VarChar, 10)
Subscr.Value = TxtSubscr.Text
Dim State As SqlParameter = testCMD.Parameters.Add
("@State", SqlDbType.VarChar, 2)
State.Value = State.SelectedValue
MyConnection.Open()
TxtCount.Text = testcmd.ExecuteScalar()
MyConnection.Close()
End Sub 2 4500
Hi Jeff,
Use cbname.selecteditem. But you have .state.selectedvalue - is 'state' the
name of your combobox? If it is, change it, because it's conficting with
the name of the parameter.
HTH,
Bernie Yaeger
"Jeff Thur" <je**@emscirc.com> wrote in message
news:4d****************************@phx.gbl... I am running a SQL Stored Procedure that will give the user a count of how many records are in the database as per certain criteria. I'm using the Execute Scalar Method. I have no problem passing values that the user inputs into Text boxes to my Stored Procedure. However I have a drop down list with a listing of the individual States, which the user selects. I am trying to use the SelectedValue of the drop down list but I am getting a message that SelectedValue is not a member of the parameter collection. Would anybody know how to pass that parameter to the Stored procedure. Below is a piece of the program to look at. Thanks for any help that can be provided.
Sub GetCount
Dim MyConnection As SqlConnection MyConnection = New SqlConnection("server='(local)'; user id='sa'; password='fritz'; database='Cutis'") Dim testCMD As SqlCommand = New SqlCommand ("EMSCOUNTER", MyConnection) testCMD.CommandType = CommandType.StoredProcedure
Dim Last As SqlParameter = testCMD.Parameters.Add ("@Last", SqlDbType.VarChar, 6) Last.Value = TxtLast.Text
Dim First As SqlParameter = testCMD.Parameters.Add ("@First", SqlDbType.VarChar, 1) First.Value = TxtFirst.Text
Dim Subscr As SqlParameter = testCMD.Parameters.Add ("@Subscr", SqlDbType.VarChar, 10) Subscr.Value = TxtSubscr.Text
Dim State As SqlParameter = testCMD.Parameters.Add ("@State", SqlDbType.VarChar, 2) State.Value = State.SelectedValue
MyConnection.Open()
TxtCount.Text = testcmd.ExecuteScalar() MyConnection.Close()
End Sub -----Original Message----- Hi Jeff,
Use cbname.selecteditem. But you
have .state.selectedvalue - is 'state' thename of your combobox? If it is, change it, because
it's conficting withthe name of the parameter.
HTH,
Bernie Yaeger
Hi Bernie,
Thats it. Also Would you know
How can I select multiple States from the drop down box
and pass them on to my SQL Query.
Thank You VERY MUCH.
Jeff........... "Jeff Thur" <je**@emscirc.com> wrote in message news:4d****************************@phx.gbl...I am running a SQL Stored Procedure that will give the user a count of how many records are in the database as per certain criteria. I'm using the Execute Scalar Method. I have no problem passing values that the user inputs into Text boxes to my Stored Procedure. However I have
a drop down list with a listing of the individual States, which the user selects. I am trying to use the SelectedValue of the drop down list but I am getting a message that SelectedValue is not a member of the parameter collection. Would anybody know how to pass
that parameter to the Stored procedure. Below is a piece of the program to look at. Thanks for any help that can be provided.
Sub GetCount
Dim MyConnection As SqlConnection MyConnection = New SqlConnection("server='(local)';
user id='sa'; password='fritz'; database='Cutis'") Dim testCMD As SqlCommand = New SqlCommand
("EMSCOUNTER", MyConnection) testCMD.CommandType = CommandType.StoredProcedure
Dim Last As SqlParameter = testCMD.Parameters.Add ("@Last", SqlDbType.VarChar, 6) Last.Value = TxtLast.Text
Dim First As SqlParameter = testCMD.Parameters.Add ("@First", SqlDbType.VarChar, 1) First.Value = TxtFirst.Text
Dim Subscr As SqlParameter = testCMD.Parameters.Add ("@Subscr", SqlDbType.VarChar, 10) Subscr.Value = TxtSubscr.Text
Dim State As SqlParameter = testCMD.Parameters.Add ("@State", SqlDbType.VarChar, 2) State.Value = State.SelectedValue
MyConnection.Open()
TxtCount.Text = testcmd.ExecuteScalar() MyConnection.Close()
End Sub
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: macyp |
last post by:
I have to pass values from one aspx page to another. The controls I
have in the first page are:
a textbox, 3 drop down lists, and 2 check boxes, and a submit button.
It is a search page, and the...
|
by: Sandy |
last post by:
Hello -
How do I get a drop down list to drop down instead of up?
Is there any way to make the text centered in the list?
Also, I now have a drop down list that was created using a Sql...
|
by: Jeff Thur |
last post by:
I am running a SQL Stored Procedure that will give the
user a count of how many records are in the database as
per certain criteria.
I'm using the Execute Scalar Method.
I have no problem passing...
|
by: clickon |
last post by:
I want to use the selected value of a drop down list to filter a data source.
When i have done this before i have used a DataSourceControl and i have just
made the drop down a control parameter,...
|
by: clickon |
last post by:
Forget about the controlParameter for the moment, for testing purposes i have
created the following
Markup:
<asp:Table ID="tblSelectRoute" runat="server" CssClass="asp-table">
<asp:TableRow>...
|
by: Dooman |
last post by:
Hello,
I am getting this error when binding a drop down list box to a
dataset:
The 'SelectedIndex' and 'SelectedValue' attributes are mutually
exclusive
I have looked at other posts and...
|
by: ArunDhaJ |
last post by:
Hi Friends,
Is it possible to pass a table as a parameter to a funtion.
whos function declaration would look some thing like this....
ALTER FUNCTION TempFunction (@TempTable TABLE, @nPId INT)
...
|
by: Redhairs |
last post by:
Is it possible to get DropDownList.SelectedValue in Page_PreInit() event
during the postback?
|
by: Dan |
last post by:
Hi,
I create 5 dropdownlist in code-behind. I want to insert their
selectedvalues in a table by making a string separated with ":"
I can get their selecedvalues but i'm stuck when i want to...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |