473,782 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored Procedures with SQLCommandBuild er

I have a very strange thing occurring in the program. I have a dataset
retrieved from a stored procedure that just select * from a table. I then
try to use the SQlCommandBuild er on the dataset, and fails. I try the same
select statement directly and not using a stored procedure and use
SQLCommandBuild er, the program works. This is a ASP.net page, and I am
stumped. I would like to use the stored procedure rather than controlling
it in the ASP.net page. Can anyone help? Thanks.
Nov 18 '05 #1
5 2840
For a start, though not the answer you're currently looking for I would
separate out all your database activity into a separate assembly.

Unfortunately I've not used SQLCommandBuild er yet, so this is all I can
currently contiribute.

FWIW
Colin

"microsoft.priv ate.windows.net server.setup" <ra***********@ shaw.ca> wrote in
message news:em******** ******@TK2MSFTN GP10.phx.gbl...
I have a very strange thing occurring in the program. I have a dataset
retrieved from a stored procedure that just select * from a table. I then
try to use the SQlCommandBuild er on the dataset, and fails. I try the same select statement directly and not using a stored procedure and use
SQLCommandBuild er, the program works. This is a ASP.net page, and I am
stumped. I would like to use the stored procedure rather than controlling
it in the ASP.net page. Can anyone help? Thanks.

Nov 18 '05 #2
To add to Colin's comment, the Data Access Application Block released by
MSFT is a nice set of pre-written
functions for DB access, and a good place to start.

http://msdn.microsoft.com/library/de...ml/daab-rm.asp

-John

"Colin Basterfield" <co************ **@hotmail.com> wrote in message
news:uV******** ******@TK2MSFTN GP09.phx.gbl...
For a start, though not the answer you're currently looking for I would
separate out all your database activity into a separate assembly.

Unfortunately I've not used SQLCommandBuild er yet, so this is all I can
currently contiribute.

FWIW
Colin

"microsoft.priv ate.windows.net server.setup" <ra***********@ shaw.ca> wrote in message news:em******** ******@TK2MSFTN GP10.phx.gbl...
I have a very strange thing occurring in the program. I have a dataset
retrieved from a stored procedure that just select * from a table. I then try to use the SQlCommandBuild er on the dataset, and fails. I try the

same
select statement directly and not using a stored procedure and use
SQLCommandBuild er, the program works. This is a ASP.net page, and I am
stumped. I would like to use the stored procedure rather than controlling it in the ASP.net page. Can anyone help? Thanks.


Nov 18 '05 #3
It has to be doable. I am sure it is just the TableMappings of the stored
procedure. The result set from the stored procedure is sp_WellProperti es,
but the SqlCommandBuild er is asking for WellProperties which is the actual
name of the table. Even when I use sqlAdaptor.Tabl eMappings.Add(" Table",
"WellProperties ") it still doesn't work. I am quite sure I have
WellProperties incorrect.in the TableMappings Add method. Is there a way to
get the actual name of the dataset that was returned by the stored
procedure? Thanks.

"John Amick" <an*******@disc ussions.microso ft.com> wrote in message
news:em******** ******@TK2MSFTN GP09.phx.gbl...
To add to Colin's comment, the Data Access Application Block released by
MSFT is a nice set of pre-written
functions for DB access, and a good place to start.

http://msdn.microsoft.com/library/de...ml/daab-rm.asp
-John

"Colin Basterfield" <co************ **@hotmail.com> wrote in message
news:uV******** ******@TK2MSFTN GP09.phx.gbl...
For a start, though not the answer you're currently looking for I would
separate out all your database activity into a separate assembly.

Unfortunately I've not used SQLCommandBuild er yet, so this is all I can
currently contiribute.

FWIW
Colin

"microsoft.priv ate.windows.net server.setup" <ra***********@ shaw.ca> wrote
in
message news:em******** ******@TK2MSFTN GP10.phx.gbl...
I have a very strange thing occurring in the program. I have a dataset
retrieved from a stored procedure that just select * from a table. I

then try to use the SQlCommandBuild er on the dataset, and fails. I try the

same
select statement directly and not using a stored procedure and use
SQLCommandBuild er, the program works. This is a ASP.net page, and I am stumped. I would like to use the stored procedure rather than controlling it in the ASP.net page. Can anyone help? Thanks.



Nov 18 '05 #4
Could you post your code? That might help someone come up with an answer
for you.

-John

"microsoft.priv ate.windows.net server.setup" <ra***********@ shaw.ca> wrote in
message news:uz******** ******@TK2MSFTN GP10.phx.gbl...
It has to be doable. I am sure it is just the TableMappings of the stored
procedure. The result set from the stored procedure is sp_WellProperti es,
but the SqlCommandBuild er is asking for WellProperties which is the actual
name of the table. Even when I use sqlAdaptor.Tabl eMappings.Add(" Table",
"WellProperties ") it still doesn't work. I am quite sure I have
WellProperties incorrect.in the TableMappings Add method. Is there a way to get the actual name of the dataset that was returned by the stored
procedure? Thanks.

"John Amick" <an*******@disc ussions.microso ft.com> wrote in message
news:em******** ******@TK2MSFTN GP09.phx.gbl...
To add to Colin's comment, the Data Access Application Block released by
MSFT is a nice set of pre-written
functions for DB access, and a good place to start.

http://msdn.microsoft.com/library/de...ml/daab-rm.asp

-John

"Colin Basterfield" <co************ **@hotmail.com> wrote in message
news:uV******** ******@TK2MSFTN GP09.phx.gbl...
For a start, though not the answer you're currently looking for I would separate out all your database activity into a separate assembly.

Unfortunately I've not used SQLCommandBuild er yet, so this is all I can currently contiribute.

FWIW
Colin

"microsoft.priv ate.windows.net server.setup" <ra***********@ shaw.ca> wrote
in
message news:em******** ******@TK2MSFTN GP10.phx.gbl...
> I have a very strange thing occurring in the program. I have a dataset > retrieved from a stored procedure that just select * from a table. I
then
> try to use the SQlCommandBuild er on the dataset, and fails. I try

the same
> select statement directly and not using a stored procedure and use
> SQLCommandBuild er, the program works. This is a ASP.net page, and I

am > stumped. I would like to use the stored procedure rather than

controlling
> it in the ASP.net page. Can anyone help? Thanks.
>
>



Nov 18 '05 #5
I have pasted the code from the original file. I am sure that it is because
it is trying to write back to the sp_WellProperti esDatasets stored
procedure. Of course this can't be done, becuase the stored proc just
retrieves the table. I then tried a table mapping, but I think I have the
wrong original table name, thus in SqlCommandBuild er it still thinks it is
coming from a table named sp_WellProperti esDatasets. Any help greatly
appreciated, thanks.

Code;
'loads each section of the WellProperties table
Sub Load_UserForm()
sqlSQLCommand = New SqlCommand( strSQL2, sqlConnect )
sqlDataAdaptor = New SqlDataAdapter( sqlSQLCommand )

'add the table mappings (parameters is name of new table name, and
original table name)
sqlDataAdaptor. TableMappings.A dd( "Table", "WellProperties " )

sqlDataAdaptor. Fill( sqlDataSet1, "Table" )
'Response.Write (sqlDataSet1.Da taSetName)

'bind to the datagrid, the key is ID field
WellProperties. Datasource() = sqlDataset1
WellProperties. DataBind()
End Sub

'save the changes back to the database
Sub SaveDatasets(s As Object, e as EventArgs)
'change a piece of data
'sqlDataset1.Ta bles("WellPrope rties").Rows(0) (2) = "Test4"
'original value is Heavy

'create the sqlcommandbuild er
Dim cbWellPropertie s As New SqlCommandBuild er( sqlDataAdaptor )

'display the update statement of the records that were changed
strDebug.Text = cbWellPropertie s.GetUpdateComm and().CommandTe xt

'push the updates to the database
sqlDataAdaptor. Update( sqlDataSet1 )

'bind to the datagrid, the key is ID field
WellProperties. Datasource() = sqlDataset1
WellProperties. DataBind()
End Sub

"John Amick" <an*******@disc ussions.microso ft.com> wrote in message
news:u9******** ******@TK2MSFTN GP11.phx.gbl...
Could you post your code? That might help someone come up with an answer
for you.

-John

"microsoft.priv ate.windows.net server.setup" <ra***********@ shaw.ca> wrote in message news:uz******** ******@TK2MSFTN GP10.phx.gbl...
It has to be doable. I am sure it is just the TableMappings of the stored
procedure. The result set from the stored procedure is sp_WellProperti es, but the SqlCommandBuild er is asking for WellProperties which is the actual name of the table. Even when I use sqlAdaptor.Tabl eMappings.Add(" Table", "WellProperties ") it still doesn't work. I am quite sure I have
WellProperties incorrect.in the TableMappings Add method. Is there a way
to
get the actual name of the dataset that was returned by the stored
procedure? Thanks.

"John Amick" <an*******@disc ussions.microso ft.com> wrote in message
news:em******** ******@TK2MSFTN GP09.phx.gbl...
To add to Colin's comment, the Data Access Application Block released by MSFT is a nice set of pre-written
functions for DB access, and a good place to start.

http://msdn.microsoft.com/library/de...ml/daab-rm.asp

-John

"Colin Basterfield" <co************ **@hotmail.com> wrote in message
news:uV******** ******@TK2MSFTN GP09.phx.gbl...
> For a start, though not the answer you're currently looking for I would > separate out all your database activity into a separate assembly.
>
> Unfortunately I've not used SQLCommandBuild er yet, so this is all I can > currently contiribute.
>
> FWIW
> Colin
>
> "microsoft.priv ate.windows.net server.setup" <ra***********@ shaw.ca>

wrote
in
> message news:em******** ******@TK2MSFTN GP10.phx.gbl...
> > I have a very strange thing occurring in the program. I have a dataset > > retrieved from a stored procedure that just select * from a table. I then
> > try to use the SQlCommandBuild er on the dataset, and fails. I try the > same
> > select statement directly and not using a stored procedure and use
> > SQLCommandBuild er, the program works. This is a ASP.net page, and

I am
> > stumped. I would like to use the stored procedure rather than
controlling
> > it in the ASP.net page. Can anyone help? Thanks.
> >
> >
>
>



Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
10758
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures execute in the database server with better performance? Please advise good references for Oracle stored procedures also. thanks!!
2
2821
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the code in stored procedures (im advocating encryption of them). When deploying an application however stored procedure seem to add another level of complexity to installation. In future we also plan to have an basic ASP app with some of the...
2
9245
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
5
3486
by: Tim Marshall | last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with interest and on reading the post describing Lauren Quantrell's SmartTree, I've run into something I don't understand: Stored Procedures. I thought stored pricedures were an Oracle/MS SQL Server thing and don't know how they work with Access Jet. I've looked at some of the help on stored procedures in A2003, but really don't understand what's going on. Can someone...
2
5459
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
45
3412
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
28
72554
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and 2005 Test Environments. What is the purpose of a view if I can just copy the vode from a view and put it into a stored procedure? Should I be accessing views from stored procedures?
7
9716
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason for this being to stop the user thinking the application has frozen when in fact it is just waiting for a long SP to complete. Another reason for doing it like this is that I also have had a problem in the past where the SP takes longer than the...
11
3444
by: peter | last post by:
I am trying to get a SQL stored procedure to use user maintained MQT implicitly which raises questions on when they are used or not used. In theory you would expect the stored procedure to pick up the MQT at the time it is bound on the creation of the static SQL. This raises the question on how you stop it or start it using a MQT as there is no option on the bind. What happens when it is rebound? What happens if the plan is made invalid...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.