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.
> >
> >
>
>