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
Similar Messages:
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
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
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
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
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
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
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
Mar 12, 2010
Is there a way opf getting the first value from a linq query so for example
[Code]....
View 2 Replies
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
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
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
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
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
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
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
Apr 15, 2010
can capture return value from a SQL by using SqlConnection SqlCommand
[Code]....
View 3 Replies
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
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
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
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
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
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
Apr 14, 2010
I am trying to fill a gridview with the data from Product table selecting few columns . I am using 3 - tier architecture and in DAL getproduct(userid) I am writing the query but cannot figure out exactly how to get that working .. here is piece of method I wrote
public List<Project> GetProjectList(int ownerId)
View 11 Replies
Mar 29, 2010
I am working on a small project. I ran the query below to get the maximum userid and increase it by 1 to create a new userid. However, when I run the query, it does not display the values that I enter into the database using insert statement. For example, if I open the table called login, I can see there are three records. If Irun the select statement, it only return one record which is the one that I enter manually when I first created the table. If I run the same select statement and give it a user id that I created, it returns the correct result.
[Code]....
View 2 Replies