473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Stored Procedures with SQLCommandBuilder

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 SQlCommandBuilder on the dataset, and fails. I try the same
select statement directly and not using a stored procedure and use
SQLCommandBuilder, 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 2819
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 SQLCommandBuilder yet, so this is all I can
currently contiribute.

FWIW
Colin

"microsoft.private.windows.netserver.setup" <ra***********@shaw.ca> wrote in
message news:em**************@TK2MSFTNGP10.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 SQlCommandBuilder on the dataset, and fails. I try the same select statement directly and not using a stored procedure and use
SQLCommandBuilder, 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**************@TK2MSFTNGP09.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 SQLCommandBuilder yet, so this is all I can
currently contiribute.

FWIW
Colin

"microsoft.private.windows.netserver.setup" <ra***********@shaw.ca> wrote in message news:em**************@TK2MSFTNGP10.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 SQlCommandBuilder on the dataset, and fails. I try the

same
select statement directly and not using a stored procedure and use
SQLCommandBuilder, 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_WellProperties,
but the SqlCommandBuilder is asking for WellProperties which is the actual
name of the table. Even when I use sqlAdaptor.TableMappings.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*******@discussions.microsoft.com> wrote in message
news:em**************@TK2MSFTNGP09.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**************@TK2MSFTNGP09.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 SQLCommandBuilder yet, so this is all I can
currently contiribute.

FWIW
Colin

"microsoft.private.windows.netserver.setup" <ra***********@shaw.ca> wrote
in
message news:em**************@TK2MSFTNGP10.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 SQlCommandBuilder on the dataset, and fails. I try the

same
select statement directly and not using a stored procedure and use
SQLCommandBuilder, 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.private.windows.netserver.setup" <ra***********@shaw.ca> wrote in
message news:uz**************@TK2MSFTNGP10.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_WellProperties,
but the SqlCommandBuilder is asking for WellProperties which is the actual
name of the table. Even when I use sqlAdaptor.TableMappings.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*******@discussions.microsoft.com> wrote in message
news:em**************@TK2MSFTNGP09.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**************@TK2MSFTNGP09.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 SQLCommandBuilder yet, so this is all I can currently contiribute.

FWIW
Colin

"microsoft.private.windows.netserver.setup" <ra***********@shaw.ca> wrote
in
message news:em**************@TK2MSFTNGP10.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 SQlCommandBuilder on the dataset, and fails. I try

the same
> select statement directly and not using a stored procedure and use
> SQLCommandBuilder, 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_WellPropertiesDatasets 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 SqlCommandBuilder it still thinks it is
coming from a table named sp_WellPropertiesDatasets. 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.Add( "Table", "WellProperties" )

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

'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.Tables("WellProperties").Rows(0)(2) = "Test4"
'original value is Heavy

'create the sqlcommandbuilder
Dim cbWellProperties As New SqlCommandBuilder( sqlDataAdaptor )

'display the update statement of the records that were changed
strDebug.Text = cbWellProperties.GetUpdateCommand().CommandText

'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*******@discussions.microsoft.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
Could you post your code? That might help someone come up with an answer
for you.

-John

"microsoft.private.windows.netserver.setup" <ra***********@shaw.ca> wrote in message news:uz**************@TK2MSFTNGP10.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_WellProperties, but the SqlCommandBuilder is asking for WellProperties which is the actual name of the table. Even when I use sqlAdaptor.TableMappings.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*******@discussions.microsoft.com> wrote in message
news:em**************@TK2MSFTNGP09.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**************@TK2MSFTNGP09.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 SQLCommandBuilder yet, so this is all I can > currently contiribute.
>
> FWIW
> Colin
>
> "microsoft.private.windows.netserver.setup" <ra***********@shaw.ca>

wrote
in
> message news:em**************@TK2MSFTNGP10.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 SQlCommandBuilder on the dataset, and fails. I try the > same
> > select statement directly and not using a stored procedure and use
> > SQLCommandBuilder, 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
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...
2
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...
2
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...
5
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...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
45
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
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...
7
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...
11
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.