Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Visual Basic 6.0 ADO & Visual Foxpro Tables
Message
From
28/10/2004 09:54:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/10/2004 16:56:25
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows 2000
Network:
Windows 2000 Pro
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00954731
Message ID:
00955263
Views:
21
>Hey Cetin,
>
>No offence intended. I was only making sure I wasn't stepping on any toes. What I need is to see some examples (lot's I hope) so I can immerse myself in this stuff and get up to speed... so I hope you can direct me to some examples of ADO access on VFP data from Visual Basic 6.
>
>To be more specific I'm just trying to update a single table's field and I keep getting an error -2147217842 everytime I call the update method on bound text fields. I tried optimistic/pessimistic client & server cursors and it keeps failing..... kinda feel like an idiot.
>
>Appreciate any help.
>
>
>thanks,
>
>Don

Don,
I'd say check version - KB: Q257790
Here is a code sample (with my perfect VB < vbg > ):
Private Sub Command1_Click()
    Const ForReading = 1, ForWriting = 2, ForAppending = 3
    Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim oCon As New ADODB.Connection
Dim oRS As New ADODB.Recordset
Dim oCommand As New ADODB.Command
Dim oParm As ADODB.Parameter
Dim myMemo As Variant
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\temp\sometext.txt", 1, 0)
myMemo = f.ReadAll
f.Close

oCon.ConnectionString = "Provider=VFPOLEDB;Data Source=d:\cetin\ddrive\temp\testdata.dbc"

' Alternative one at a time
'oCommand.CommandText = "insert into employee (emp_id,first_name,last_name,birth_date,notes)" & _
'  " values ('test3','First3','Last3',{^1961/1/19},?)"
'oCommand.CommandType = adCmdText
'Set oParm = oCommand.CreateParameter("Notes", adVarChar, adParamInput, Len(myMemo), myMemo)
'oCommand.Parameters.Append oParm
'oCon.Open
'oCon.Execute ("set null off")
'oCommand.ActiveConnection = oCon
'oCommand.Execute
'oCon.Close

oCon.Mode = adModeShareDenyNone
oCon.Open
oCon.CursorLocation = adUseClient
oCon.Execute ("set null off")
oRS.Open "employee", oCon, adOpenKeyset, adLockBatchOptimistic, adCmdTable
oRS.AddNew
oRS.Fields("emp_id").Value = "test1"
oRS.Fields("First_Name").Value = "First1"
oRS.Fields("Last_Name").Value = "Last1"
oRS.Fields("hire_date").Value = #1/13/2004#
oRS.AddNew
oRS.Fields("emp_id").Value = "test2"
oRS.Fields("First_Name").Value = "First2"
oRS.Fields("Last_Name").Value = "Last2"
oRS.Fields("hire_date").Value = #2/29/2000#
oRS.Fields("Notes").Value = myMemo
oRS.UpdateBatch
oRS.Close
oCon.Close

End Sub
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform