WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

ado connection problem

 
   Home -> Office other -> Client RSS
Next:  How can I quickly change the table name in a quer..  
Author Message
Paul M

External


Since: Mar 06, 2008
Posts: 24



(Msg. 1) Posted: Wed May 27, 2009 7:05 am
Post subject: ado connection problem
Archived from groups: microsoft>public>frontpage>client (more info?)

Hi
I have created a connection to a database but I get the following error
What can be the cause of such an error
.........................................................................
ADODB.Recordset error '800a0e7d'

The connection cannot be used to perform this operation. It is either closed
or invalid in this context.

........................................................................................

Here is the code


If Len(ipMemberID)>0 AND IsNumeric(ipMemberID) Then
sUpdate="SELECT * FROM tblMembers WHERE ID=" & ipMemberID
Set opConnection=Server.CreateObject("ADODB.Connection")
Set opRecordset=Server.CreateObject("ADODB.Recordset")
opRecordset.open sUpdate, opConnection
If NOT opRecordset.Eof Then



sUpdate = "UPDATE ( sql here)


opConnection.execute(sUpdate)

'Close the recordset object
opRecordset.Close
Set opRecordset=Nothing
%>
Back to top
Login to vote
Stefan B Rusynko

External


Since: Oct 11, 2003
Posts: 2128



(Msg. 2) Posted: Thu May 28, 2009 5:25 am
Post subject: Re: ado connection problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

No need to open the record set or check if it is found
- If the ipMemberID is not found, no update will occur

Plus you need to first open your DB connection, and set the Command Type to &H0001

If value1 is a text value, and field1 is the field you are updating then:

IF Len(ipMemberID)>0 AND IsNumeric(ipMemberID) THEN
sUpdate = "UPDATE tblMembers Set field1='" & value1 & " WHERE ID=" & ipMemberID
Const ADOadCmdText = &H0001
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open ConnStr 'where ConnStr is your DB connection string to open the DB
Set objCmd = Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = sUpdate
objCmd.CommandType = ADOadCmdText
objCmd.Execute
Set objCmd = Nothing
objConn.Close
Set objConn = Nothing
END IF


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


"Paul M" <paul.DeleteThis@newsgroup.co.uk> wrote in message news:%23U5UMHr3JHA.5276@TK2MSFTNGP04.phx.gbl...
| Hi
| I have created a connection to a database but I get the following error
| What can be the cause of such an error
| ........................................................................
| ADODB.Recordset error '800a0e7d'
|
| The connection cannot be used to perform this operation. It is either closed
| or invalid in this context.
|
| .......................................................................................
|
| Here is the code
|
|
| If Len(ipMemberID)>0 AND IsNumeric(ipMemberID) Then
| sUpdate="SELECT * FROM tblMembers WHERE ID=" & ipMemberID
| Set opConnection=Server.CreateObject("ADODB.Connection")
| Set opRecordset=Server.CreateObject("ADODB.Recordset")
| opRecordset.open sUpdate, opConnection
| If NOT opRecordset.Eof Then
|
|
|
| sUpdate = "UPDATE ( sql here)
|
|
| opConnection.execute(sUpdate)
|
| 'Close the recordset object
| opRecordset.Close
| Set opRecordset=Nothing
| %>
|
|
Back to top
Login to vote
Paul M

External


Since: Mar 06, 2008
Posts: 24



(Msg. 3) Posted: Mon Jun 08, 2009 1:05 pm
Post subject: Re: ado connection problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks Stefan

Best wishes
Paul M

"Stefan B Rusynko" <sbr_enjoy.RemoveThis@hotmail.com> wrote in message
news:eri1JZ33JHA.1196@TK2MSFTNGP03.phx.gbl...
> No need to open the record set or check if it is found
> - If the ipMemberID is not found, no update will occur
>
> Plus you need to first open your DB connection, and set the Command Type
> to &H0001
>
> If value1 is a text value, and field1 is the field you are updating then:
>
> IF Len(ipMemberID)>0 AND IsNumeric(ipMemberID) THEN
> sUpdate = "UPDATE tblMembers Set field1='" & value1 & " WHERE ID=" &
> ipMemberID
> Const ADOadCmdText = &H0001
> Set objConn = Server.CreateObject("ADODB.Connection")
> objConn.Open ConnStr 'where ConnStr is your DB connection string
> to open the DB
> Set objCmd = Server.CreateObject("ADODB.Command")
> Set objCmd.ActiveConnection = objConn
> objCmd.CommandText = sUpdate
> objCmd.CommandType = ADOadCmdText
> objCmd.Execute
> Set objCmd = Nothing
> objConn.Close
> Set objConn = Nothing
> END IF
>
>
> --
>
> _____________________________________________
> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
> "Warning - Using the F1 Key will not break anything!" (-;
> _____________________________________________
>
>
> "Paul M" <paul.RemoveThis@newsgroup.co.uk> wrote in message
> news:%23U5UMHr3JHA.5276@TK2MSFTNGP04.phx.gbl...
> | Hi
> | I have created a connection to a database but I get the following error
> | What can be the cause of such an error
> | ........................................................................
> | ADODB.Recordset error '800a0e7d'
> |
> | The connection cannot be used to perform this operation. It is either
> closed
> | or invalid in this context.
> |
> |
> .......................................................................................
> |
> | Here is the code
> |
> |
> | If Len(ipMemberID)>0 AND IsNumeric(ipMemberID) Then
> | sUpdate="SELECT * FROM tblMembers WHERE ID=" & ipMemberID
> | Set opConnection=Server.CreateObject("ADODB.Connection")
> | Set opRecordset=Server.CreateObject("ADODB.Recordset")
> | opRecordset.open sUpdate, opConnection
> | If NOT opRecordset.Eof Then
> |
> |
> |
> | sUpdate = "UPDATE ( sql here)
> |
> |
> | opConnection.execute(sUpdate)
> |
> | 'Close the recordset object
> | opRecordset.Close
> | Set opRecordset=Nothing
> | %>
> |
> |
>
>
Back to top
Login to vote
Display posts from previous:   
       Home -> Office other -> Client All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
 Office
  Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support