Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Stored Query and DATASETs don't get along ?

Reply
Thread Tools

Stored Query and DATASETs don't get along ?

 
 
Lorenzo
Guest
Posts: n/a
 
      07-06-2005
Hello there,
in my training in data access I am getting lost with somenthing maybe pretty
easy but I don't seem to find a way out.

I would like to bind some data that I get form a simple SELECT stored query
in access called sp_Leggi that looks like this

SELECT TOP 10 * FROM [Clienti];

All works well when I perfom the databind to a data reader with the
following:

Sub BindData()
'1. Create a connection
Dim myConnection as New
OleDbConnection(ConfigurationSettings.AppSettings( "connectionString"))

'2. Create the command object, passing in the SQL string
Const strSQL as String = "sp_Leggi"
Dim myCommand as New OleDbCommand(strSQL, myConnection)
myCommand.CommandType = CommandType.StoredProcedure

'Set the datagrid's datasource to the datareader and databind
myConnection.Open()
DataGrid1.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
DataGrid1.DataBind()
End Sub


IT DOES NOT WORK when I do the same binding through a dataset !!! I do the
follwoing:

Sub BindData()
'1. Create a connection
Dim myConnection as New
OleDbConnection(ConfigurationSettings.AppSettings( "connectionString"))

Dim myDataSet as New DataSet()

Const strSQL as String = "sp_Leggi"

Dim myAdapter as New OleDbDataAdapter(strSQL, myConnection)

myAdapter.fill(myDataSet)

DataGrid1.DataSource = myDataSet
DataGrid1.DataBind()

End Sub

It is interesting that it works fine when I use the same code with a real
STORED PROC with SQL server no errors at all.

The error I get is:
[OleDbException (0x80040e14)not valid SQL



Any help greatly appreciated
Lorenzo


 
Reply With Quote
 
 
 
 
Fiaz Ali Saleemi
Guest
Posts: n/a
 
      07-12-2005
Hi Lorenzo

I think in datasource properties of controls it didn't accept Datareader
although DataSet, DataTable, DataView, Hashtable can be used.

Regards
Fiaz Ali Saleemi

"Lorenzo"
<CuTT-!thISoFfonlyLeAveMyNamelorenzoWithNoNuMBErS98776@L eaveMyCountry!!!ITAL
IANlodging.it.NOSPAM> wrote in message
news:(E-Mail Removed)...
> Hello there,
> in my training in data access I am getting lost with somenthing maybe

pretty
> easy but I don't seem to find a way out.
>
> I would like to bind some data that I get form a simple SELECT stored

query
> in access called sp_Leggi that looks like this
>
> SELECT TOP 10 * FROM [Clienti];
>
> All works well when I perfom the databind to a data reader with the
> following:
>
> Sub BindData()
> '1. Create a connection
> Dim myConnection as New
> OleDbConnection(ConfigurationSettings.AppSettings( "connectionString"))
>
> '2. Create the command object, passing in the SQL string
> Const strSQL as String = "sp_Leggi"
> Dim myCommand as New OleDbCommand(strSQL, myConnection)
> myCommand.CommandType = CommandType.StoredProcedure
>
> 'Set the datagrid's datasource to the datareader and databind
> myConnection.Open()
> DataGrid1.DataSource =
> myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
> DataGrid1.DataBind()
> End Sub
>
>
> IT DOES NOT WORK when I do the same binding through a dataset !!! I do the
> follwoing:
>
> Sub BindData()
> '1. Create a connection
> Dim myConnection as New
> OleDbConnection(ConfigurationSettings.AppSettings( "connectionString"))
>
> Dim myDataSet as New DataSet()
>
> Const strSQL as String = "sp_Leggi"
>
> Dim myAdapter as New OleDbDataAdapter(strSQL, myConnection)
>
> myAdapter.fill(myDataSet)
>
> DataGrid1.DataSource = myDataSet
> DataGrid1.DataBind()
>
> End Sub
>
> It is interesting that it works fine when I use the same code with a real
> STORED PROC with SQL server no errors at all.
>
> The error I get is:
> [OleDbException (0x80040e14)not valid SQL
>
>
>
> Any help greatly appreciated
> Lorenzo
>
>




 
Reply With Quote
 
 
 
 
Lorenzo
Guest
Posts: n/a
 
      07-14-2005
Many thanks Ali for your reply. I will proceed my training if case access
using DataSets then.
I am still curios though maybe would be nice to implement some StoredQuery
support in the OleDbCommand class don't you think.

Maybe not since sqlexpress might take over any access support what a shame
!!!
What is your opinion?

L.


"Fiaz Ali Saleemi" <(E-Mail Removed)> ha scritto nel messaggio
news:%(E-Mail Removed)...
> Hi Lorenzo
>
> I think in datasource properties of controls it didn't accept Datareader
> although DataSet, DataTable, DataView, Hashtable can be used.
>
> Regards
> Fiaz Ali Saleemi
>
> "Lorenzo"
> <CuTT-!thISoFfonlyLeAveMyNamelorenzoWithNoNuMBErS98776@L eaveMyCountry!!!ITAL
> IANlodging.it.NOSPAM> wrote in message
> news:(E-Mail Removed)...
>> Hello there,
>> in my training in data access I am getting lost with somenthing maybe

> pretty
>> easy but I don't seem to find a way out.
>>
>> I would like to bind some data that I get form a simple SELECT stored

> query
>> in access called sp_Leggi that looks like this
>>
>> SELECT TOP 10 * FROM [Clienti];
>>
>> All works well when I perfom the databind to a data reader with the
>> following:
>>
>> Sub BindData()
>> '1. Create a connection
>> Dim myConnection as New
>> OleDbConnection(ConfigurationSettings.AppSettings( "connectionString"))
>>
>> '2. Create the command object, passing in the SQL string
>> Const strSQL as String = "sp_Leggi"
>> Dim myCommand as New OleDbCommand(strSQL, myConnection)
>> myCommand.CommandType = CommandType.StoredProcedure
>>
>> 'Set the datagrid's datasource to the datareader and databind
>> myConnection.Open()
>> DataGrid1.DataSource =
>> myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
>> DataGrid1.DataBind()
>> End Sub
>>
>>
>> IT DOES NOT WORK when I do the same binding through a dataset !!! I do
>> the
>> follwoing:
>>
>> Sub BindData()
>> '1. Create a connection
>> Dim myConnection as New
>> OleDbConnection(ConfigurationSettings.AppSettings( "connectionString"))
>>
>> Dim myDataSet as New DataSet()
>>
>> Const strSQL as String = "sp_Leggi"
>>
>> Dim myAdapter as New OleDbDataAdapter(strSQL, myConnection)
>>
>> myAdapter.fill(myDataSet)
>>
>> DataGrid1.DataSource = myDataSet
>> DataGrid1.DataBind()
>>
>> End Sub
>>
>> It is interesting that it works fine when I use the same code with a real
>> STORED PROC with SQL server no errors at all.
>>
>> The error I get is:
>> [OleDbException (0x80040e14)not valid SQL
>>
>>
>>
>> Any help greatly appreciated
>> Lorenzo
>>
>>

>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? Francisco Garcia ASP .Net Web Services 3 04-13-2006 05:53 PM
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? Francisco Garcia ASP .Net 2 04-13-2006 10:41 AM
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? news.microsoft.com ASP .Net Web Services 0 04-12-2006 09:07 AM
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? news.microsoft.com ASP .Net 0 04-12-2006 09:07 AM
Stored Procedures and DataSets =?Utf-8?B?U2FuZHk=?= ASP .Net 2 03-11-2005 06:01 PM



Advertisments