Showing posts with label dataset. Show all posts
Showing posts with label dataset. Show all posts

Wednesday, March 28, 2012

the best way to do this

hey all,

i need to get a sum of columns in my dataset. but also, i need the sum to be
over certain rows in my dataset. as result from using .Select or .RowFilter.

Is this possible?

thanks,
rodcharsum is an aggregate function supported against
a DataTable.

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net

"rodchar" <rodchar@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:C5D04A15-8E5F-4500-BF8B-9154B9E4CEFF@dotnet.itags.org.microsoft.com...
> hey all,
> i need to get a sum of columns in my dataset. but also, i need the sum to
> be
> over certain rows in my dataset. as result from using .Select or
> .RowFilter.
> Is this possible?
> thanks,
> rodchar

the best way to do this

hey all,
i need to get a sum of columns in my dataset. but also, i need the sum to be
over certain rows in my dataset. as result from using .Select or .RowFilter.
Is this possible?
thanks,
rodcharsum is an aggregate function supported against
a DataTable.
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net
"rodchar" <rodchar@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:C5D04A15-8E5F-4500-BF8B-9154B9E4CEFF@dotnet.itags.org.microsoft.com...
> hey all,
> i need to get a sum of columns in my dataset. but also, i need the sum to
> be
> over certain rows in my dataset. as result from using .Select or
> .RowFilter.
> Is this possible?
> thanks,
> rodchar

Monday, March 26, 2012

The correct syntax for returning a DataSet

I realise this is a beginners question but i would be grateful for some help
Untill now i have been using Datareaders for example;
Public Class Catalog
Public Shared Function SP_GetBB() As SqlDataReader
' Create the connection object
Dim connection As New SqlConnection(ConnectionString)
' Create and initialize the command object
Dim command As New SqlCommand("SP_GetBB", connection)
command.CommandType = CommandType.StoredProcedure
' Open the connection
connection.Open()
' Return a SqlDataReader to the calling function
Return command.ExecuteReader(CommandBehavior.CloseConnection)
End Function
Can anyone tell me how to convert the above to return a Dataset
I have got this far but am not sure how to finish:
Public Class Catalog
Public Shared Function SP_GetBB() As System.Data.DataSet
' Create the connection object
Dim connection As New SqlConnection(ConnectionString)
' Create and initialize the command object
Dim command As New SqlCommand("SP_GetBB", connection)
command.CommandType = CommandType.StoredProcedure.......
...........................
many thanks
martin
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Fo...sp-net/200510/1Hi Martin,
you need a DataAdapter to fill your DataSet, for example:
Public Function SelectSqlSrvRows(dataSet As DataSet, connection As String,
query As String) As DataSet
Dim conn As New SqlConnection(connection)
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = new SqlCommand(query, conn)
adapter.Fill(dataset)
Return dataset
End Function
For a description look at
http://msdn.microsoft.com/library/d...op
ic.asp
Alex
http://www.DotNet42.com - The Answer to Your DotNet question
"martinharvey via webservertalk.com" wrote:

> I realise this is a beginners question but i would be grateful for some he
lp
>
> Untill now i have been using Datareaders for example;
> Public Class Catalog
> Public Shared Function SP_GetBB() As SqlDataReader
> ' Create the connection object
> Dim connection As New SqlConnection(ConnectionString)
> ' Create and initialize the command object
> Dim command As New SqlCommand("SP_GetBB", connection)
> command.CommandType = CommandType.StoredProcedure
> ' Open the connection
> connection.Open()
> ' Return a SqlDataReader to the calling function
> Return command.ExecuteReader(CommandBehavior.CloseConnection)
> End Function
> Can anyone tell me how to convert the above to return a Dataset
> I have got this far but am not sure how to finish:
>
> Public Class Catalog
> Public Shared Function SP_GetBB() As System.Data.DataSet
> ' Create the connection object
> Dim connection As New SqlConnection(ConnectionString)
> ' Create and initialize the command object
> Dim command As New SqlCommand("SP_GetBB", connection)
> command.CommandType = CommandType.StoredProcedure.......
> ...........................
> many thanks
> martin
>
> --
> Message posted via webservertalk.com
> http://www.webservertalk.com/Uwe/Fo...sp-net/200510/1
>
Alex wrote:
>Hi Martin,
>you need a DataAdapter to fill your DataSet, for example:
>Public Function SelectSqlSrvRows(dataSet As DataSet, connection As String,
>query As String) As DataSet
> Dim conn As New SqlConnection(connection)
> Dim adapter As New SqlDataAdapter()
> adapter.SelectCommand = new SqlCommand(query, conn)
> adapter.Fill(dataset)
> Return dataset
>End Function
>For a description look at
>http://msdn.microsoft.com/library/d...o
pic.asp
>Alex
>http://www.DotNet42.com - The Answer to Your DotNet question
>
>[quoted text clipped - 29 lines]
many thanks for your help with this
Cheers
martin
Message posted via http://www.webservertalk.com

The correct syntax for returning a DataSet

I realise this is a beginners question but i would be grateful for some help

Untill now i have been using Datareaders for example;

Public Class Catalog
Public Shared Function SP_GetBB() As SqlDataReader

' Create the connection object
Dim connection As New SqlConnection(ConnectionString)
' Create and initialize the command object
Dim command As New SqlCommand("SP_GetBB", connection)
command.CommandType = CommandType.StoredProcedure
' Open the connection
connection.Open()
' Return a SqlDataReader to the calling function
Return command.ExecuteReader(CommandBehavior.CloseConnect ion)
End Function

Can anyone tell me how to convert the above to return a Dataset
I have got this far but am not sure how to finish:

Public Class Catalog
Public Shared Function SP_GetBB() As System.Data.DataSet
' Create the connection object
Dim connection As New SqlConnection(ConnectionString)
' Create and initialize the command object
Dim command As New SqlCommand("SP_GetBB", connection)
command.CommandType = CommandType.StoredProcedure.......
...........................

many thanks

martin

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Fo...sp-net/200510/1Hi Martin,

you need a DataAdapter to fill your DataSet, for example:

Public Function SelectSqlSrvRows(dataSet As DataSet, connection As String,
query As String) As DataSet
Dim conn As New SqlConnection(connection)
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = new SqlCommand(query, conn)
adapter.Fill(dataset)
Return dataset
End Function

For a description look at
http://msdn.microsoft.com/library/d...lasstopic.a sp

Alex

http://www.DotNet42.com - The Answer to Your DotNet question

"martinharvey via DotNetMonster.com" wrote:

> I realise this is a beginners question but i would be grateful for some help
>
> Untill now i have been using Datareaders for example;
> Public Class Catalog
> Public Shared Function SP_GetBB() As SqlDataReader
> ' Create the connection object
> Dim connection As New SqlConnection(ConnectionString)
> ' Create and initialize the command object
> Dim command As New SqlCommand("SP_GetBB", connection)
> command.CommandType = CommandType.StoredProcedure
> ' Open the connection
> connection.Open()
> ' Return a SqlDataReader to the calling function
> Return command.ExecuteReader(CommandBehavior.CloseConnect ion)
> End Function
> Can anyone tell me how to convert the above to return a Dataset
> I have got this far but am not sure how to finish:
>
> Public Class Catalog
> Public Shared Function SP_GetBB() As System.Data.DataSet
> ' Create the connection object
> Dim connection As New SqlConnection(ConnectionString)
> ' Create and initialize the command object
> Dim command As New SqlCommand("SP_GetBB", connection)
> command.CommandType = CommandType.StoredProcedure.......
> ...........................
> many thanks
> martin
>
> --
> Message posted via DotNetMonster.com
> http://www.dotnetmonster.com/Uwe/Fo...sp-net/200510/1
Alex wrote:
>Hi Martin,
>you need a DataAdapter to fill your DataSet, for example:
>Public Function SelectSqlSrvRows(dataSet As DataSet, connection As String,
>query As String) As DataSet
> Dim conn As New SqlConnection(connection)
> Dim adapter As New SqlDataAdapter()
> adapter.SelectCommand = new SqlCommand(query, conn)
> adapter.Fill(dataset)
> Return dataset
>End Function
>For a description look at
>http://msdn.microsoft.com/library/d...lasstopic.a sp
>Alex
>http://www.DotNet42.com - The Answer to Your DotNet question
>> I realise this is a beginners question but i would be grateful for some help
>>
>[quoted text clipped - 29 lines]
>>
>> martin

many thanks for your help with this

Cheers

martin

--
Message posted via http://www.dotnetmonster.com

Saturday, March 24, 2012

The DataSet: I have doubts

Here are my doubts about the dataSet object. These doubts may arise from my not understanding this object properly so please let me know if this is the case.

i see these problems:

1. if a user closes the page mid session i lose my in memory dataSet so all the dataGrid editing my user has done since the database was last updated is lost.

2. when updating the parent database I need to fill the dataAdapter first in case anyone else has edited the rows beforehand. all this toing and froing is expensive.

Also, how do i decide to update the parent database from the dataSet. Can I do it automatically i.e. on a timer or do I do it after every 5 dataGrid row edits?

thanks.1. You would lose any data had you hand written the text boxes and filled the table dynamically with them. It's not the fault of the DataSet or some weird communication.

2. Again, you should be checking data validity before hand any way. The only difference here, with DataGrids, is that you know exactly which row was modified before hand very easily.

3. [How do I...] Why not whenever the user presses update? The few times that I have used datasets I have never held them in the session. I bind them to a datagrid and forget. When the user edits, the info I need to update the row is right there.