|
-
Oct 16th, 2000, 05:50 AM
#1
Thread Starter
Lively Member
I have a database that I can connect to using the following but I want to be able to add records using the .AddNew command and it brings up an "Object or Providers not Capable of preforming requested operation " error.
Any ideas?
Simon
Dim UserCon As ADODB.Connection
Dim UserRs As ADODB.Recordset
Dim UserFld As ADODB.Field
Dim strSQLUser As String
Dim strUserDNS As String
strUserDNS = frmView.userdatasource.ConnectionString
Set UserCon = New ADODB.Connection
UserCon.Open strUserDNS
strSQLUser = "SELECT userdata.viewpic, userdata.viewtip, userdata.viewupdate" & _
" FROM userdata" & _
" WHERE userdata.userlogin = " & Chr(39) & getusr() & Chr(39) & Chr(59)
'frmSearch.mmissdatasource.RecordSource = strSQLstatus & adCmdText
Set UserRs = New ADODB.Recordset
UserRs.CursorType = adOpenForwardOnly
UserRs.Open strSQLUser, UserCon, , , adCmdText
If UserRs.EOF = False Then
'For Each UserFld In UserRs
frmView.mipicss.Checked = UserRs("ViewPic")
frmView.miview.Checked = UserRs("ViewTip")
frmView.miupdate.Checked = UserRs("ViewUpdate")
'Next
Else
'UserRs.MoveLast
UserRs.AddNew
' UserRs("userlogin") = getusr()
' UserRs("viewpic").Value = True
' UserRs("viewtip").Value = True
' UserRs("viewupdate").Value = False
' UserRs.Update
End If
UserRs.Close
Set UserRs = Nothing
UserCon.Close
Set UserCon = Nothing
-
Oct 16th, 2000, 06:36 AM
#2
Hyperactive Member
One suggestion have you try removing the ', , ,adCmdText' from the end
UserRs.Open strSQLUser, UserCon, , , adCmdText
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Oct 16th, 2000, 06:45 AM
#3
Thread Starter
Lively Member
I got that bit working the bit that I cannot get to work is:
UserRs.AddNew
UserRs("userlogin") = getusr()
UserRs("viewpic").Value = True
UserRs("viewtip").Value = True
UserRs("viewupdate").Value = False
UserRs.Update
It errors on userlogin when it tries to go to the user login object however it works on the other fields.
Simon
-
Oct 16th, 2000, 06:55 AM
#4
Hyperactive Member
Could have something to do with your trying to enter text, try this:-
UserRs("userlogin") = "'" & getusr() & "'"
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Oct 16th, 2000, 06:58 AM
#5
Thread Starter
Lively Member
It is more that it cannot recognise that userlogin is a valid field name and erorrs because of that!
Simon
-
Oct 16th, 2000, 07:03 AM
#6
Hyperactive Member
Your select statement doesn't include the userlogin in field
"SELECT USERDATA.USERLOGIN, userdata.viewpic, userdata.viewtip, userdata.viewupdate" & _
" FROM userdata" & _
" WHERE userdata.userlogin = " & Chr(39) & getusr() & Chr(39) & Chr(59)
'frmSearch.mmissdatasource.RecordSource = strSQLstatus & adCmdText
You must include the all field names before the FROM clause or it will not pick up that field
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Oct 16th, 2000, 07:14 AM
#7
Thread Starter
Lively Member
Thanks for spotting that I learn more and more about this everyday.
Thanks for your help
Simon
-
Oct 16th, 2000, 08:16 AM
#8
New Member
hi,
you can try this code.
You must give to the recordset the possibility of write over Data base...
StrutturaTabs.Open "Select * from <tab name>", <connectionstring>, , adLockOptimistic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|