DataSource Controls :: How To Access The Return Value Of The SQLDataReade

Feb 15, 2010

accessing the return value of the SQLDataReader. My code is below. Actually the variable that I assigned my SQLDatareader object to is say HasRows property=true. But I am having trouble accessing the return value. And I get the error when I use the following code .Text =SQLDataReader("Contact Name").ToString I get the following error message: Invalid attempt to read when no data is present.

con = New SqlConnection(ConfigurationManager.ConnectionStrings("Connect").ConnectionString)
Dim getDirectorsCMD As SqlCommand = New SqlCommand("dbo.spGetDirector", con)
getDirectorsCMD.CommandType = CommandType.StoredProcedure
Dim myParm As SqlParameter = getDirectorsCMD.Parameters.Add("@BuildingTID", SqlDbType.Int, 15)
myParm.Value = ddlBuilding.SelectedValue
[code]...

View 3 Replies


Similar Messages:

Access :: Trying To Create A DataReader To Return A Counted Value From An Access Database?

Feb 3, 2010

I am trying to create a DataReader to return a counted value from an Access Database. It all works if it finds some rows, but falls apart when there is no total.

My code is as follows (highlights);

[Code]....

The error that gets thrown is:

Description:

An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: BoxesOut

Source Error:

Line 43: if(reader2["BoxesOut"] != System.DBNull.Value)

View 5 Replies

DataSource Controls :: Why Does Cmd.ExecuteNonQuery() Return -1

Mar 3, 2010

I have created a stored procedure that reset my tables' identity value. The store procedure works fine when I didrectly run it in my ms sql server 2008. It reset my table Identity value However, when I call it from my function reset, it returns -1, and does not reset my table identitity value. The function to restet my identity value is:

[Code]....

My stored procedure is

[Code]....

To call the the function:

Dim result
As
Integer = util.resetTableIdentity("myTable", "id", 60)
util.print(result)

I got result is -1, and it does ot reset my table identity. Why? How to resove it?

View 4 Replies

DataSource Controls :: Return Value From Sql In GridView?

Aug 28, 2010

I have textbox for searching a Names in My database. I return the information from the Select Statement in GridView, but i want to know the number of affected rows. How to do that?

View 3 Replies

DataSource Controls :: How To Access Database Once With Big Resultset Or Access Multiple Times On The Fly

Jun 17, 2010

I have a situation where I am accessing a database multiple times and I'm wondering if it is necessary.

I have a GridView with a template column with a hyperlink to "Get Results" and on the RowDataBound event I have it check the batch number against the database and see if results exist and then if they don't, hide the link.

So when viewing the page if there is 20 rows in the gridview it is effectively doing 20 queries.

I was wondering if it is a better idea to query the database once with all "batches" and load it into a datatable, then on the RowDataBound event query the datatable. The only issue I see with this is there is currently 40,000 batches and grows daily.

View 1 Replies

DataSource Controls :: How To Return A Single Row Where There Is A One To Many Relationship

Jun 23, 2010

I have 2 tables. Table_A has one to many relationship with Table_B.

For example. Table_A has an ApplicantKey and in Table_B I am storing (Resume_name and CoverLetter_name for the Applicant). Joined by ApplicantKey

Now when I join them and execute the query obviously it returns me two rows. But what I want is that it should return only one row with Columns like Resume_name, CoverLetter_Name

View 2 Replies

DataSource Controls :: Return ID Of Inserted Record

Jan 12, 2010

I followed this BRILLIANT article and found out how to make a data layer, i just need the insert method in this code to return the ID of the record inserted.

For example, when the user captures the details, the save button is clicked, i will want to display in a label "Your Reference Number is "

try and have look at the article so you will understand how the code is, so it will not be hard to edit my code.

[URL]

View 7 Replies

DataSource Controls :: Return Range Of Dates

Feb 25, 2010

I have this query:

[Code]....

I want to select dates that also fallin the range. Heres the scenario: I have an event from 01/20/2010 TO 01/25/2010. So right now it would only return a date of 01/20/2010. How could I return 01/20/2010, 01/21/2010 , 01/22/2010, 01/23/2010, 01/24/2010, 01/25/2010? Mind you only a start and end date are in the database.

View 3 Replies

DataSource Controls :: Return New ID From LINQ InsertOnSubmit?

Jan 21, 2010

I have an autoincrement ID on some table.I need to know what is the ID of the new row when I add the object using InsertOnSubmit, but this method returns void.What is the common way of doing this.

View 1 Replies

DataSource Controls :: Return First Value From A Linq Query?

Mar 12, 2010

Is there a way opf getting the first value from a linq query so for example

[Code]....

View 2 Replies

DataSource Controls :: Return String Value From The Function?

Mar 7, 2010

i try to return string value from the function i wrote for getting string value from the table for that i havecommon stored procedure

public string getdata(string str)
{
string datanew;

[code]...

View 2 Replies

DataSource Controls :: How To Retrieve The Return Value From Stored Procedure

Jun 16, 2010

i want to retrieve the return value of following stored procedure in my Data Access Layer of ASP

CREATE PROCEDURE Procedure_login

View 3 Replies

DataSource Controls :: Return Values From Select Statement?

Feb 8, 2011

I have a select statement in a stored procedure and want to be able to retrieve the key column value (PRODUCTID)and return it as Output when Select statement is executed on input Parameter (NAME).

addition, return two further output values (COST,TOTAL).

note the grid control expects to receive all values at once! so i need to get out these values at the same instance of execution.

Select productID,COST,QUANTITY,NAME,TOTAL,DATE
FROM PRODUCTS
WHERE NAME=@NAME

View 2 Replies

DataSource Controls :: SQL Statement - Don't Want To Return Duplicate Columns

Mar 11, 2010

I have the following simple stored procedure:

ALTER PROCEDURE GetadiByPhiNo

@PhiNo int

SELECT adirefno, adidescription

FROM aditable

WHERE adiphino = @PhiNo

Here is an example of data returned:

1 Skin diesease

2 Cough

3 Cough

4 Rash

You notice "Cough" is in the adidescription column twice. I would like to return only one row for adidescription with the same value. So what I want returned is this:

1 Skin diesease

2 Cough

4 Rash

View 8 Replies

DataSource Controls :: Return Value From Stored Procedure To C# Code Behind?

Mar 16, 2010

So I am getting this error message:

Cannot implicitly convert type 'System.Data.SqlClient.SqlParameter' to 'string' I have a stored procedure on SQL 2000 returning an email from a database table (aspnet_Membership). The email type from the table is nvarchar. I have a method (in C# in the code behind) that gets that value. But the debugger doesn't like the last line:

return returnEmail; // returnEmail is a string variable we created to capture the stored procedure's return value

I've tried doing returnEmail.toString() in several places, but still get the same error message for the last line of code (returning the email).

This is the stored procedure:

View 3 Replies

DataSource Controls :: How To Return Variables From Stored Procedure

Feb 1, 2010

I have a stored procedure which returns a value to state if the userlogin is valid. but i want to return the data and store it in a data session as i will require the user details in the checkout page.

is it best to get individual parameters out of the stored procedure then assign the variables to a datatable which is then assigned to session Or how can i get all the details returned from the stored procedure for the table? not sure which would be the most effective solution?

View 9 Replies

DataSource Controls :: Return Unique Rows : T-SQL Query

Jun 11, 2010

I have an SQL database table like the following:

ID // Code // Shape

The ID is the integer identifier.

On one line the Code may be OX01 and shape Hexagon for example

Then the next line the code is still OX01 but the shape is Triangle.

What I want to do is be able to pull back data for every line that is equal to a unique Code column. in the above example OX01 Hexagon would be returned but not OX01 Triangle.

I've tried using SELECT DISTINCT but it brings back all records and doesn't filter them correctly.

I've considered having another column which could have Child/Parent data so that only the parent is returned but i'm sure there must be a better way of doing this.

View 2 Replies

DataSource Controls :: Can Capture Return Value From A SQL By Using SqlConnection SqlCommand

Apr 15, 2010

can capture return value from a SQL by using SqlConnection SqlCommand

[Code]....

View 3 Replies

DataSource Controls :: How To Check Two Queries Return Result Is Same

Feb 26, 2010

how to wrote stored procedure for check two queries result this result is same return true value its not same return false value

View 2 Replies

DataSource Controls :: Execute SP With Return Parameter From ODBC?

Aug 9, 2010

[Code]....

The code:

[Code]....

[Code]....

I getting the error:ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near
'@P1'.

View 2 Replies

DataSource Controls :: Check Query Return Value Or Not In LINQ

Jun 2, 2010

i have a Linq query that check something in database

after that i want to check if record find in database or not

dim re = From r in db.mytable _
where r.ID = _ID
Select r

how can i check the re return somthing or empty

View 1 Replies

DataSource Controls :: Return Default Value From LINK Query?

Sep 2, 2010

I am using the query listed below which includes multiple joins, in the result of the query I need to do some value replacement valuesExample: db.ASSETS.BUILDING_ID=300 that ID does not exist in db.BUILDINGS, in that case I need to return BUILDING_ID=0, db.BUILDINGS.NAME="Unassigned"

[Code]....

View 2 Replies

DataSource Controls :: FormView InsertItem Return Scope_Identity?

Sep 24, 2010

I've looked all over for this answer and had to resort to several resources. I wanted to post this here because it was so hard for me to find a simple example. If it exist other places then please excuse my post and put references to it on a reply.

So, How do I return the Primary Key Identity when I click the control with the 'Insert' command on a FormView? (With very least minimal code) Help me if there's a quicker way.

<InsertItem>
<SqlDatasource ID="sqlSource">
<InsertCommand = "INSERT INTO ... ; SELECT @ID = Scope_Identity()">
<InsertParameters>
<asp:Parameter Name="ID" Direction="Output" Type="Int32" />
</InsertParameters>
</SqlDatasource>
</InsertItem>

Protected Sub sqlSource_Inserted()
Dim cmd as System.Data.Common.DbCommand = e.command
Dim strID as String
sqlSource.InsertParameters("ID").DefaultValue = cmd.Parameters("@ID").Value.ToString()
strID = sqlSource.InsertParameters("ID").DefaultValue.ToString()
lblResults.Text = strID
End Sub

View 1 Replies

DataSource Controls :: Return User And A Set Of Values From The Same Sprocedure?

Oct 11, 2010

I have a user table with userID, userName ...the standards. I also have a "Material" table with materialID, materialName, etc.

I combine these in another table "UsersMaterial" with userID and materialID, depending on which materials the user has chosen (between 0 and 5).

Now I need a stored procedure that returns the user information + the set of materials that is mapped to the user.

But I can't see how I can return one row of user information combined with a set of the user materials? Do I join or can I return a set + one row?

View 1 Replies

Forms Data Controls :: Return Dataset As Datasource For Gridview

Dec 5, 2010

I am trying to return a dataset. I must be doing something wrong. The returned dataset in this sample code indicates there is a datatable, Users, but there are no datarows. What am I doing wrong? This example is only using the rows.count, but of course I really need to use the whole datatable as the datasource for a gridview.

[Code]....

Public Function getmyds() As DataSet
Dim dsUser1 As DataSet = New DataSet()
Dim tbUser1 As DataTable = dsUser1.Tables.Add("Users")
tbUser1.Columns.Add("UserName")
tbUser1.Columns.Add("Days Remaining")
tbUser1.Columns.Add("UserAccountControl")
Dim rwDefaultUser1 As DataRow = tbUser1.NewRow()
rwDefaultUser1("UserName") = "John Smith"
rwDefaultUser1("Days remaining") = 100
rwDefaultUser1("userAccountControl") = "Enabled"
Return dsUser1
End Function

View 2 Replies







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