Using datagrid selected value to input to parameter in stored procedure

could someone please let me know if i am declaring the parameter wrong or have the wrong VB CODE.  I receive my 3 column headers in my datagrid but the parameter isn't doing anything



@Machcusid nvarchar  OUTPUT

SELECT     dbo.Machine.machcustomID, dbo.Problem.ProblemDesc, dbo.Request.ReqDate
FROM         dbo.Machine INNER JOIN
                      dbo.Request ON dbo.Machine.machID = dbo.Request.MachID INNER JOIN
                      dbo.Problem ON dbo.Request.ProblemID = dbo.Problem.ProblemID
where machcustomID = @Machcusid


Private Sub LSBmachcusid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LSBmachcusid.SelectedIndexChanged


SqlSelectCommand2.Parameters("@Machcusid").Value = LSBmachcusid.SelectedItem.Value


End Sub

End Class

12/9/2005 4:10:23 PM 29906 articles. 0 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 37

You have declared the parameter as OUTPUT in the stored proc. It should be an input parameter which is what all the parameters are by default if you dont specify anything. So, remove the keyword OUTPUT after the parameter.
You could check out BOL for more info on OUTPUT parameters. You use them to send values out from the stored proc.

Dinakar Nethi
Life is short. Enjoy it.
12/9/2005 7:43:43 PM
thanks I understand that now, someone showed me, but i still took output off and when i execute the code in VB.NET i recevie blank values for @machcusid when i know i should recieve data
12/9/2005 8:02:00 PM

Maybe I don't understand what you are trying to achieve, but...

If I understand the code correctly, you have a dropdown that is trying to do a filter on the grid?

If so, don't fill your dataset before you set the sql parameter, or it will be blank.

I think you wanted to do this:

SqlSelectCommand2.Parameters("@Machcusid").Value = LSBmachcusid.SelectedItem.Value



In addition to removing the OUTPUT in your stored procedure, and you should define a length on the nvarchar as well like:


@Machcusid nvarchar(50)


SELECT     dbo.Machine.machcustomID, dbo.Problem.ProblemDesc, dbo.Request.ReqDate
FROM         dbo.Machine INNER JOIN
                      dbo.Request ON dbo.Machine.machID = dbo.Request.MachID INNER JOIN
                      dbo.Problem ON dbo.Request.ProblemID = dbo.Problem.ProblemID
where machcustomID = @Machcusid

12/9/2005 11:11:11 PM

Thank You for the idea but i figured out my problem.  Really weird solution

i went back to the orignal query in SQL and found the problem.  Seem that the data would not pass correctly when i made my parameter @machcusid a NVARCHAR.  However, I changed it to a VARCHAR and still no luck.  The strangest thing is i had to specify the length of the VARCHAR to 10 characters in both the QUERY code and the VB.NET code


Thank You everyone for the ideas seems the easiest way to fix a problem is go back to the start of it

12/10/2005 2:22:57 AM

Similar Artilces:

Using a DataGrid to display values from a Stored Procedure with Multiple Selects in
Hello, I am trying to use a datagrid to display the results of a stored procedure. The Stored procedure has multiple select statements. I am only able to extract the results of the first query - what do I need to do to display the results of all in one query?? the stored procedure code: CREATE PROCEDURE che_wsales_total AS SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED declare @period varchar(10), @startp varchar(50), @finp varchar(50), @starty varchar(50) SET @period= 'PERIOD 10' set @startp='2003-09-28' set @finp='2003-11-01' set @starty='2002-12-29'...

Using Selected Values From Drop Down Boxes As Stored Procedure Parameters
I have two drop down boxes.  I would like to use the selected values from each drop down box.  The selected values will be used as parameters for a existing Stored Procedure. It would go like this:User selects Value A from the first drop down boxUser selects Value B from the second drop down boxA confirmation screen will say "You have selected Value A, Value B is this correct???"  A YES / NO button will be available for them to click.  If the user clicks YES on the button, the stored procedure should be kicked off.  Value A and Value B will be now inpu...

Strange case in stored procedures input parameters with null input value
I recently discovered this weired situation and wondering if this is a bug. This is related to executing stored procedures with null input parameters. Here is the scenario. Say I create a proc called tempProc as below: create proc tempProc (@myNum numeric(10,0), @myChar char(10)) as begin print '@myNum is: %1!',@myNum print '@myChar is: %1!',@myChar end I expect stored procedure will return an error message when null input values are passed into the parameter. But the proc succeeded: exec tempProc 0,null Result: @myNum is: 0 @myChar ...

How to select a field value from a selected row from a DataGrid in order to use it as a parameter
I am working on a web application, and I have two DataGrids.  Then end-User is supposed to select a row from one of the grids, and the event should select a key from that row in order to use it as a parameter to fill the other DataGrid.  I have been trying to do so, but I dont work the same way as I used to do it in windows applications.   I would appreciate any suggestions,   Thanks. Is there some code we can look at? I've done similar things and I've never had any problem with them. In the first grid have a select column, when it is clicked you can catch the Sel...

VB.NET SQL stored procedure: procedure has no parameters and arguments were supplied
VB.NET SQL stored procedure: procedure has no parameters and arguments were supplied Please assist me:This erorr message is produce when calling the stored procedure in vb.netProcedure AutomateMatterNumber has no parameters and arguments were supplied."MS SQL 2000stored procedure:*/CREATE PROCEDURE dbo.AutomateMatterNumber ASDECLARE @nextMtr AS BIGINTDECLARE @dtToday AS DATETIMEIF NOT EXISTS(SELECT * FROM tempMatter WHERE DATEDIFF(dd,DateSet,GETDATE())=0 )BEGINDELETE FROM tempMatter-- incase there are some old recordsSELECT TOP 1 @nextMtr= CONVERT(BIGINT, MatterNumber) + 1 ,@dtTod...

How to Retrive the store procedure return value in Ado.Net by using Dot Net?
Hi i am thiru. i try to create the small search engine. so that i have wrote the store procedure for it. thats given below.Create procedure FindtestThree @Name varchar(25), @Location varchar(25), @EmpId varchar(25) as select * from TbInfo where Name like + '%' + @Name + '%' select * from TbInfo where Location like + '%' + @Location + '%' select * from hi where ComName like + '%' + @EmpId + '%' Exec FindtestThree 'aa','a','d' ----------------------------------------- The above procedure return t...

Return Value when using CLR stored procedure. (Edit: For use in SQL side paging)
I have a stored procedure that I put together using the CLR.  The basic idea is the have a query that can accept any number of values.  I havent included the portion of the code that handles smalldatetime searches and I havent yet finished the logic to handle sql data type constraints but I have been working on paging using SQL's Row_Number().  The code below works but I havent been able to come up with a way to find out either how many pages the result set has or how many total rows in the result set.  I thought there might be a way to use a procedure's Return Va...

How to transfer a GUID created using into a SQL database using a stored procedure
I am able to create a guid using: Public Function GetGUID() As String ' Returns a new GUID Return System.Guid.NewGuid.ToString End Function however when I try to add this to a parameter using the following: Me.cmdSpAddOptions.Parameters("@QuoteDetailID").Value = GetGUID() I get an error, I have also tried this: Dim uidQuoteDetail As String = GetGUID() Dim myuid = New System.Guid(uidQuoteDetail) Me.cmdSpAddOptions.Parameters("@QuoteDetailID").Value = myuid but get the error "Object must implement IConvertible" A...

sql count using stored procedure withing stored procedure
I have a stored procedure that among other things needs to get a total of hours worked. These hours are totaled by another stored procedure already. I would like to call the totaling stored procedure once for each user which required a loop sort of thing for each user name in a temporary table (already done) total = result from execute totaling stored procedure Can you help with this Thanks It would be easier if you can change the stored procedure into a function. Once you do that, the total can be calculated easily with something like thisSelect Sum(dbo.CalculateHours(User...

2nd Datagrid on Stored Procedure with Input parameter
Need some help to fix this error msg: ‘------------------------------------------------ Procedure 'spGetSpouseDetails' expects parameter '@MemberID', which was not supplied. Line 265: sqlDaSpouse.Fill(dsViewSpouse) ‘------------------------------------------------ I have 2 datagrids 1 to display family members 2nd to show they spouses. By selecting (Button Colums “Select”) on 1st datagrid I am getting member id (SelectedItem.Cells.Item number) then using it as a input parameter in my store procedure I’d like to pull spouse details and fill 2nd grid with that info. ...

How do I use the return value from a SQL stored procedure?
I want to be able to use the returned number to set a Label accordingly.Something like this:if the return value == 1 then Label1.Text = "Correct" else Label1.Text = "Wrong" What is the correct syntax for this?  I couldn't find this answer. If you've just got one return parameter, I usually stick with ExecuteScalar. This will execute a stored procedure and return an object, which is taken from the first row and first column of whatever the stored procedure returns.So at the end of the stored procedure, after doing what you need to do, add a select stat...

Populating Datagrid from a stored procedure using a parameter
I've modified the productdetails page in the IbuySpyStore ( to list the items by ModelNumber in a datagrid. For example, Product ID ModelName ModelNumber Cost 123 Blue Tang SM 111 $89.99 124 Blue Tang MD 111 $99.99 125 Blue Tang Lg 111 $109.99 I'm using ModelNumber as the parameter in the querystring and would like to display all items with the same model n...

referencing values from variables to SQL store procedure parameters
This is a multi-part message in MIME format. ------=_NextPart_000_0014_01C33594.E5E1FA90 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, In Powerbuilder, I've declared a local store procedure to pass values = into SQL store procedure parameters which then goes off and triggers = some events. I've successfully passed account name to @ps_name (declared = as varchar(40) but fail when passing address varchar(160) to @ps_address = (declared as varchar(160). As powerbuilder does not have varchar nor = text as data...

Using Tables as Input Parameters in ADO Stored Procedures
Hi. I use MSSQL 2008 and Delphi 7. The SQL stored procedure has an input parameter of a table type. My application has an array defined as a TIntegerDynArray. I want to use this array as the input parameter for the stored procedure. In my datamodule I have a TADOStoredProc. The parameter's datatype is defaulted to ftUnknown. I get a runtime error during the assignment of the value to the parameter. The stored procedure is a work-in-progess and I have no problem if I have to change it. I need to do a series of data updates within a database transaction. The input parameter was...

Web resources about - Using datagrid selected value to input to parameter in stored procedure -

Parameter - Wikipedia, the free encyclopedia
A parameter (from the Ancient Greek παρά , "para", meaning "beside, subsidiary" and μέτρον , "metron", meaning "measure"), in its common meaning, ...

fb_source Parameter - Facebook-Entwickler
This document lists the complete list of values for the fb_source parameter that is returned with th...

Google / Firefox Parameter - Flickr - Photo Sharing!
HS what?

Cat 8: TIA performance standards committee chairman previews parameters of forthcoming twisted-pair cable ...
Category 8, the next-generation twisted-pair cabling specification, is still in development, but the outlook looks quite positive that it will ...

Philippine president asks for 'parameters' of Mayon Volcano tours
Philippine president asks for 'parameters' of Mayon Volcano tours People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, Apr, May, ...

Alternatives to boolean parameters
... ) { PrintLine ( item . Name ); if ( printDetails ) { PrintLine ( item . Description ); } } } Aha! Now can see that the boolean parameter ...

Exporting Error (Error in Parameter...: Apple Support Communities
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability ...

Apple tech monitors device aging, adjusts operating parameters to ensure optimal performance
... describing a method of monitoring the aging of a device's electronics, comparing the data with a global average and modifying operating parameters ...

Is it poor programming practice to pass parameters as objects?
... a free, community-powered network of 100+ Q&A sites . Risser asked: So, we've got a guy who likes to write methods that take Objects as parameters, ...

Parameter Short Film Competition sponsored by Grolsch
Grolsch presents Parameter The A.V. Club Short Film Competition Please Enter Your Date of Birth Ineligible entry Enter For people over the age ...

Resources last updated: 1/8/2016 9:32:30 AM