Return value instead of databinding ?

L

Lelle

hello!

how can i return this value to a varible instead of bind it to a gridview

Me.GridView2.DataSource = Me.SqlDataSource1

Me.SqlDataSource1.SelectCommand = "SELECT [Anvandare_Fornamn] FROM
[WebappOrders_Mailbox] WHERE [AnvandareUserid] = " & "'" & anvid & "'"

Me.GridView2.DataBind()

/ kind.... Lelle
 
L

Lars Netzel

Hi

I don't know if you are using OLDEB or SQL but it doesn't really matter
except you have to choose the right object for your solution.

Use an Oledbcommand (or sqlcommand) and then use the "ExecuteScalar"

Asuming you have a myConnection object already.. here's an example

Dim myCommand As New SqlCommand("SELECT [Anvandare_Fornamn] FROM
[WebappOrders_Mailbox] WHERE [AnvandareUserid] = " & "'" & anvid & "'",
myConnection)

Dim myVariable As String

myConnection.Open()

myVariable = myCommand.ExecuteScalar

myConnection.Close()



Best Regards/

Lars Netzel
 
L

Lelle

thanks for you answer. i forgot to tell that this is asp.net 2.0 and
i have used the design view in VS2005 to create a sqlsource.

now i want to programmatically manipulate the output from this sqlsource


Lars Netzel said:
Hi

I don't know if you are using OLDEB or SQL but it doesn't really matter
except you have to choose the right object for your solution.

Use an Oledbcommand (or sqlcommand) and then use the "ExecuteScalar"

Asuming you have a myConnection object already.. here's an example

Dim myCommand As New SqlCommand("SELECT [Anvandare_Fornamn] FROM
[WebappOrders_Mailbox] WHERE [AnvandareUserid] = " & "'" & anvid & "'",
myConnection)

Dim myVariable As String

myConnection.Open()

myVariable = myCommand.ExecuteScalar

myConnection.Close()



Best Regards/

Lars Netzel



Lelle said:
hello!

how can i return this value to a varible instead of bind it to a gridview

Me.GridView2.DataSource = Me.SqlDataSource1

Me.SqlDataSource1.SelectCommand = "SELECT [Anvandare_Fornamn] FROM
[WebappOrders_Mailbox] WHERE [AnvandareUserid] = " & "'" & anvid & "'"

Me.GridView2.DataBind()

/ kind.... Lelle
 
L

Lars Netzel

ok, I haven't touched the 2.0 after it totally crashed my computer ( i guess
having VS.NET 2003 and the 2.0 beta was not a good idea.. so I don't think
I can help you more.

But After ALWAYS having problems with graphically "automatic-click-and-Drop"
wizard objects made in Visual Studio I now always prefer to do this things
maually.

best regards
/Lars Netzel


Lelle said:
thanks for you answer. i forgot to tell that this is asp.net 2.0 and
i have used the design view in VS2005 to create a sqlsource.

now i want to programmatically manipulate the output from this sqlsource


Lars Netzel said:
Hi

I don't know if you are using OLDEB or SQL but it doesn't really matter
except you have to choose the right object for your solution.

Use an Oledbcommand (or sqlcommand) and then use the "ExecuteScalar"

Asuming you have a myConnection object already.. here's an example

Dim myCommand As New SqlCommand("SELECT [Anvandare_Fornamn] FROM
[WebappOrders_Mailbox] WHERE [AnvandareUserid] = " & "'" & anvid & "'",
myConnection)

Dim myVariable As String

myConnection.Open()

myVariable = myCommand.ExecuteScalar

myConnection.Close()



Best Regards/

Lars Netzel



Lelle said:
hello!

how can i return this value to a varible instead of bind it to a
gridview

Me.GridView2.DataSource = Me.SqlDataSource1

Me.SqlDataSource1.SelectCommand = "SELECT [Anvandare_Fornamn] FROM
[WebappOrders_Mailbox] WHERE [AnvandareUserid] = " & "'" & anvid & "'"

Me.GridView2.DataBind()

/ kind.... Lelle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top