DataSource Controls :: Returning String Value Using Stored Procedure And Linq

Feb 7, 2010

I am having problems returning a string value through a stored procedure/linq to a label. Everything works fine if I return an integer value but I cant get a string value to bind to a label. I get the error message

Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value,
NumberFormatInfo NumberFormat) +201
Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) +66
[InvalidCastException: String "System.Data.Linq.SqlClient.SqlPr" to 'Integer' is invalid‚]

This is the stored procedure
ALTER PROCEDURE test
AS
Select ProductName
From Products

This is the vb page
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim db As New DataClassesDataContext
Dim product As Integer = db.test.ToString
Label1.Text = product
End Sub

This is the aspx page
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</form>

View 1 Replies


Similar Messages:

DataSource Controls :: Returning Single String Value Using Linq And Stored Procedure

Jun 21, 2010

I can return single integer values when using stored procedures with Linq but I cant get single string values returned.

View 2 Replies

DataSource Controls :: Stored Procedure Not Returning Value

May 15, 2010

I call this stored procedure with a dataset. It always returns a 0 but should return a 1 or 2. Does anybody know why it isn't returning a 1 or 2.

ALTER PROCEDURE dbo.sp_InsertLinkVote
@LinkId int,
@LinkVoter nvarchar(50),
@LinkVotesDateTime datetime,
@LinkVotesGoodBad bit
AS
/* SET NOCOUNT ON */
 
If EXISTS
(SELECT
*
FROM
LinkVotes
WHERE
LinkId=@LinkId
and
LinkVoter = @LinkVoter )RETURN
1
ELSE
INSERT INTO
dbo.LinkVotes (LinkId,LinkVoter,LinkVotesDateTime,LinkVotesGoodBad)VALUES
(@LinkId,@LinkVoter,@LinkVotesDateTime,@LinkVotesGoodBad)RETURN
2

Here is were a call it in my code behind.
Dim VoteCheck
As
Integer
Dim InsertVote
As
New DataSetStoredProceduresTableAdapters.QueriesTableAdapter
VoteCheck = InsertVote.sp_InsertLinkVote(LinkId, User.Identity.Name, DateAndTime. Now,
True)
'0 is a good vote.
If VoteCheck = 0
Then

It seems to insert and not insert correctly, I just cannot get it to return the correct value.

View 4 Replies

DataSource Controls :: Returning Value From Stored Procedure

Jun 23, 2010

I am developing a page in ASP.Net where I have the user enter a letter into a textbox. They then click a submit button and I all of the userids that start with that letter are to be displayed. So I need the SP to go through the database and match first letters with what was entered. Here is what I have as my code for the SP:

CREATE PROCEDURE dbo.exp2 @testchar Char(1)
declare @flag as char(2)
set @flag = @testchar + '%'
select userid
from ex_database
where userid like @flag

View 6 Replies

Forms Data Controls :: Returning Single String Result Through Stored Procedure

Jun 22, 2010

I am trying to return single string result through a stored procedure and Linq. This works fine when I test the stored procedure but it is not returning the value to the page. The value returned is always 0 which is the return value. This is the stored procedure:

ALTER PROCEDURE Login
@CustomerName nvarchar(50),
@Password nvarchar(50) output
As
Select @Password=Password
From Customers
Where Customers.CustomerName=@CustomerName

This is the vb
ALTER PROCEDURE Login
@CustomerName nvarchar(50),
@Password nvarchar(50) output
As
Select @Password=Password
From Customers
Where Customers.CustomerName=@CustomerName is the code created by the designer

This is the designer function
<FunctionAttribute(Name:="dbo.Login")> _
Public Function Login(<Parameter(Name:="CustomerName", DbType:="NVarChar(50)")> ByVal customerName

As String, <Parameter(Name:="Password", DbType:="NVarChar(50)")> ByRef password As String) As IntegerDim result
As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), customerName, password)
password = CType(result.GetParameterValue(1),String)
End Function

View 4 Replies

DataSource Controls :: Stored Procedure Returning Error?

May 24, 2010

Im trying use a storedprocedure where depending on the status of the room if ='Vacant' And checkIn =date and the result will be put in a gridview, but i kept returning an error that says, "Conversion failed when convertng datetime from character string". Heres the code.

Caller:

[Code]....

Stored Procedure:

[Code]....

GridviewFiller:

[Code]....

View 7 Replies

DataSource Controls :: Stored Procedure And Function Returning Same Shape

Jan 26, 2010

I have problem with a stored procedure and function that return the same shape, but as they are different methods LINQ won' t let me cast between the two. Please see code for the two SPROCs below (This is actually simplified to represent the problem, so please don't spend lots of time explaining alternative ways of writing the function/sproc.)

Table Valued Function
"getCategories()"
SELECT categoryName, categoryID FROM categories
SPROC "getUnusedCategories"
SELECT categoryName, categoryID FROM CategoryInstances cI
FROM dbo.SMAN_getCategories(@SiteMANID, @SectionID) c
LEFT JOIN @EntityResultsTable er

View 2 Replies

DataSource Controls :: Eliminate Returning Of Empty Table From Stored Procedure

Jul 12, 2010

I have a Procedure which should return only 1 Record on selecting record according to Priority.

BEGIN
DECLARE @Accounts nvarchar(MAX)
SELECT @Accounts = ISNULL([map_user_modules].[Accounts], '') FROM [map_user_modules]
WHERE [map_user_modules].[id_user] = 231 AND [map_user_modules].[id_module] = 5
IF ((@Accounts = '') OR (@Accounts = 'All'))
SELECT @Accounts = null

BEGIN
Select @@ROWCOUNT as Priority2
END
IF @@ROWCOUNT = 1
BEGIN
Return
END

BEGIN
Select @@ROWCOUNT as Priority3
END
IF @@ROWCOUNT = 1
BEGIN
Return
END

BEGIN
Select @@ROWCOUNT as Priority4
END
IF @@ROWCOUNT = 1
BEGIN
Return
END

In the above statement Suppose we take a scenario where Select @@ROWCOUNT as Priority3 is executed, I get two tables returned, One is the Table returned by Select @@ROWCOUNT as Priority3 and the other is the Table returned by Select @@ROWCOUNT as Priority2 which has no Records. How can I eliminate the Empty table that returns no records.

View 1 Replies

DataSource Controls :: Stored Procedure Returning Null But Executes At SQL Server

Jul 1, 2010

I am using
SqlHelper.ExecuteDataset(MyConnectionString, CommandType.StoredProcedure, "GetInformation", new SqlParameter("@ID", ID));

In my stored Procedure, I am doing a lot of calculation with joins and it took 19 sec to execute at my sql Server 2008. My application had been working perfectly for 5 days but now as database increases, I found a problem that my connection is breaking at that point. At Sql Server, it execute fine but when I add a breakpoint and watch the stored procedure is returning null.

View 2 Replies

DataSource Controls :: Linq And Stored Procedure ?

Mar 2, 2010

I have created one stored Procedure as

[code]...

I am not getting the result with extra column c.I am not getting what is the Problem.In sql server,It's working fine.

View 2 Replies

DataSource Controls :: Run Stored Procedure Using Linq?

Feb 12, 2010

Is it posible to run a stored procedure using linq? I dont mean one that returns a table i just mean one that runs a set of transactions exec sp_MyProc @Var or something?

View 1 Replies

DataSource Controls :: Using LINQ Passing The Name Of The Stored Procedure Dynamically?

Feb 23, 2010

I have an application where depending on what the user selects run a different stored procedure.

I am using LINQ and am passing the stored procedure name into a sub that will run the stored procedure and return values that I am loading into a DDL.

For example I want to pass the procedure name "GetProducts_Hats" to the sub and not hardcode it.

Protected Sub LoadParamDropDowns(
ByVal SqlObjToExec
As
String )

I am passing the storedprocedure name in parameter SqlObjToExec

so instead of

values = mydb.GetProducts_Hats

I want to code it to be a variable

values = mydb.SqlObjToExec

But the above code does not work.

View 7 Replies

DataSource Controls :: Sending A String To Stored Procedure Using An IN

May 18, 2010

I am confused here as to how to handle this. I have a stroed procedure that using the IN clause like so:

[Code]....

Now, partners can be either a single partner ID like so: 12345 or it can be many like: 12345, 22222, 33333Here is the sqlDataReader from my code:

[Code]....

When partner_list contains only one partner id like "12345" it works fine. If it has more than one then the DataReader states that there are no rows in the reader? I also tried to send the dealer list as a string with ticks, like '12345','22222','33333' but that doesnt work either.

View 6 Replies

DataSource Controls :: Stored Procedure Count To String

Jun 27, 2010

I have a several count stored procedures that are binding to gridview nicely for individual items. I now want a ful count of row so I use a stored procedure with:

[Code]....

Which works fine when testing in the DB and returns results like it should. My problem is that for the life me I cannot work how to display the results to a Label.Text or how to do it when my calendar has posted back thats where @LogDate comes from).

View 8 Replies

DataSource Controls :: Passing Query String Value To Stored Procedure

Mar 30, 2010

I'm trying to pass the text value of a text box as a query string value to a stored procedure. I was hoping someone could point me in the right direction. Button Code:

[Code]....

Stored Procedure:

[Code]....

The results page datalist:

[Code]....

Code Behind of results page:

[Code]....

I'm sure i've got this entirely backwards. However if I change the NULL value in the stored procedure with some string value (eg."Donkeys") it pulls all the values that contain "Donkeys" into the datalist on my results page.

View 2 Replies

DataSource Controls :: Execute Stored Procedure Using A String Variable

Jun 22, 2010

Is it possible to save execute stored proc command in a string variable and then execute string variable?
Does this logic fits into LINQ2SQL? Why I want to do this - INstead of passing user control references to server, I want to save user control values to string in client side java script and then pass string to server to do actual stored proc execution. Hopefully this will improve performance.

View 3 Replies

DataSource Controls :: ADO.Net (C#) Connection String - Update Stored Procedure

Feb 24, 2010

My question is: I have update stored procedure in my database (simple update stmt) I am finding difficulty in writing a ADO.Net(C#) connection string for update stored procedure. i have 4 columns and i first 3 columns have constant values. The 4th column values needs to be updated. At the same time i need to increment and then update the table.

View 2 Replies

DataSource Controls :: ObjectDataSource Sorting And Paging In Gridview Using LINQ Stored Procedure Methods?

Jan 31, 2010

I started learning LINQ, So i thought of just creating gridview with sorting and paging using objectdatasource using LINQ. So i got this link

[URL] which Brian Orrel tell us how to do using IQueryable Interface. but i have nearly 300 lines of stored procedure which joins nearly 20 tables. so i thought of creating a stored procedure and using that instead of IQuerytable.

[code]...

View 7 Replies

ADO.NET :: Linq To SQL Stored Procedure Returning Out Parameter "ref"

Dec 18, 2010

I always have this problem returning an out parameter from sql server using linq. So I have to use other means may be dataset. The following is the stored procedure: ALTER PROCEDURE [dbo].[InsertIntoTestProfile]

View 3 Replies

DataSource Controls :: How To Convert The Oracle Stored Procedure To Sqlserver 2005 Stored Procedure

Apr 2, 2010

This is surareddy. i nead some small clarification in the "Stored Procedure"

how to convert the oracle Stored Procedure to sqlserver2005/2008 Stored Procedure.

right now i am enhancing the project that project already developed the oracle Stored Procedure. now our company is using sqlserver 2005/2008.

how to convert the Oracle Stored Procedure to sqlserver 2005 Stored Procedure

View 4 Replies

DataSource Controls :: Do Not Use Or Call Any Stored Procedure But It Says "Could Not Find Stored Procedure 'xxxxx'?

Dec 9, 2010

Initially, I have tried to use stored procedure. But I changed my mind and preferred to call sql query in codebase with command text. However, it stills tries to find initially-called stored procedure (which is neither called or exists).I think that it is related caching. But I tried it with different browsers it did not work.What might be the reason?

View 4 Replies

DataSource Controls :: Execute A Stored Procedure Within A Stored Procedure?

Jan 18, 2010

Does anybody if it is possible that a stored procedure returns rows which is the result of the execution of another sp? Something like..

[Code]....

View 11 Replies

DataSource Controls :: How To Call A Stored Procedure In Another Stored Procedure

May 13, 2010

i want to return output parameter from 1 storeprocedure. into another stored procedure.

View 7 Replies

ADO.NET :: Stored Procedure Returning ObjectResult

Feb 20, 2011

I am having issues with the stored procedure returning an ObjectResult and then how do I return this is a list of type List.

View 2 Replies

Returning Date From Stored Procedure In VB.Net?

Jun 4, 2010

I want to execute a method on VB.Net to return a date which is in the stored procedure. I tried using ExecuteScalar but it doesnt work it retruns error

'Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query'

below is the code

Public Function GetHolidaydate(ByVal struserID as String) As DateTime
Dim objArgs1 As New clsSQLStoredProcedureParams
objArgs1.Add("@userID", Me.Tag)
objArgs1.Add("@Date", 0, 0, ParameterDirection.Output)
Return (CDate(ExecuteScalar(clsLibrary.MyStoredProcedure.GetHolidayDate, objArgs1)))
End Function

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved