Dim MyConn As Odbc.OdbcConnection = New Odbc.OdbcConnection(StrConn)
Dim odbcCommand_search As OdbcCommand = New OdbcCommand("Select TM0001.*,TM0011.office_name from TM0001 inner join TM0011 on TM0001.office_id = TM0011.office_id ORDER BY syain_id ", MyConn)
Hi,I think this is the right place to "place" my own question...!!!
Well,I want to update an integer field in my table...What I do is the following:
Dim myConnection As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True")
Dim myCommand As SqlDataAdapter = New SqlDataAdapter("select HitCounter from HitsAndDate", myConnection)
Dim ds As New DataSet
myConnection.Open()
myCommand.Fill(ds, "HitsAndDate")
Application("TotalHits") = ds.Tables("HitsAndDate").Rows(0)("HitCounter")
Application("TotalHits") += 1
ds.Tables("HitsAndDate").Rows(0)("HitCounter") = Application("TotalHits")
myCommand.Update(ds, "HitsAndDate")
myConnection.Close()
[:'(] The problem is that when I try to run the application,an error occurs,which is:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
Source Error:
Line 37: 'Dim sqlbuilder As SqlCommandBuilder = New SqlCommandBuilder(myCommand)
Line 38: 'Dim newds As DataSet = ds.GetChanges(DataRowState.Modified)
Line 39: myCommand.Update(ds, "HitsAndDate")
Line 40:
Line 41: 'UpdateCommand.Update(ds, "HitsAndDate")
natasha_arri...
Member
698 Points
343 Posts
Re: bout hyperlink?
Jan 31, 2007 07:02 AM|LINK
natasha_arri...
Member
698 Points
343 Posts
Re: bout hyperlink?
Feb 02, 2007 01:34 AM|LINK
satish ,
can u help me about showing my data in textbox? but only the rist entry of my database?
coz it outputs the last entry not the first one....pls?
i have a new thread for that... thanks....
satish_nagde...
Contributor
6572 Points
1432 Posts
Re: bout hyperlink?
Feb 02, 2007 02:28 AM|LINK
you case use Order By clause in your query.
if you want only one record then in SQL Server it has option like
Select Top 1 From table order by Pid Desc, it will give u only one record.
thanks,
satish.
natasha_arri...
Member
698 Points
343 Posts
Re: bout hyperlink?
Feb 02, 2007 03:26 AM|LINK
here is my code
Dim MyConn As Odbc.OdbcConnection = New Odbc.OdbcConnection(StrConn)
Dim odbcCommand_search As OdbcCommand = New OdbcCommand("Select TM0001.*,TM0011.office_name from TM0001 inner join TM0011 on TM0001.office_id = TM0011.office_id ORDER BY syain_id ", MyConn)
but still it putput the last record...
natasha_arri...
Member
698 Points
343 Posts
Re: bout hyperlink?
Feb 02, 2007 03:33 AM|LINK
got it working already!
thanks....
raikkonen
Member
106 Points
157 Posts
A Quick-easy Update Question...!!!
Feb 02, 2007 05:38 AM|LINK
[:)]
Hi,I think this is the right place to "place" my own question...!!!
Well,I want to update an integer field in my table...What I do is the following:
Dim myConnection As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True") Dim myCommand As SqlDataAdapter = New SqlDataAdapter("select HitCounter from HitsAndDate", myConnection) Dim ds As New DataSet myConnection.Open() myCommand.Fill(ds, "HitsAndDate") Application("TotalHits") = ds.Tables("HitsAndDate").Rows(0)("HitCounter") Application("TotalHits") += 1 ds.Tables("HitsAndDate").Rows(0)("HitCounter") = Application("TotalHits") myCommand.Update(ds, "HitsAndDate") myConnection.Close()[:'(] The problem is that when I try to run the application,an error occurs,which is:
-----------------------------------------------------------------------------
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
Source Error:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
How Can I get rid of this error....Any idea?
Thanks in advance...
satish_nagde...
Contributor
6572 Points
1432 Posts
Re: A Quick-easy Update Question...!!!
Feb 02, 2007 06:15 AM|LINK
hi Raikkonen,
you've not specified update command for DataAdapter
take a look at this link it contains simplest example http://www.java2s.com/Code/CSharp/Database-ADO.net/UpdatetableusingSqlDataAdapter.htm
should be helpful i think.
thanks,
satish.
natasha_arri...
Member
698 Points
343 Posts
about resizing window?
Feb 02, 2007 07:19 AM|LINK
help pls need it bad
are u familiar with resizing a window?
example this website asp.net...
when i click the buttons at the upper right corner with the maximize ,minimize etc... button
the page seems to be put in the center....
everytime the screen is resize the page follows also.... how do you think can i do that?
thnx