Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: chris smith
  Where is chris smith?
 Yorkshire CH CH
 Barbados
 chris smith
 Tags
Subject: RE: updateing a mySQL database
Thread ID: 311071 Message ID: 311119 # Views: 39 # Ratings: 0
Version: Visual FoxPro 6 Category: Off-topic
Date: Tuesday, June 28, 2011 10:58:08 PM         
   


> >
> > First you need to have a connection string. You would use either ODBC or OLEDB connection string depending on what you are using (my preference is OLEDB). You can find the connection strings here:
> >
> > http://www.connectionstrings.com/mysql
> >
> > Then with ODBC it is something like:
> >
> >
handle = SQLStringConnect( < your connection string here > )
> > lcCommand = 'insert into myTable (field1, field2) values (?m.v1, ?m.v2)'
> > 
> > v1 = "String value"
> > v2 = datetime()
> > 
> > SQLExec(m.handle, m.lcCommand)
> > 
> > SQLDisconnect(m.handle)
> > 

> >
> > Using OLEDB you can use ADO. It is harder at first but I think better on the long run. ie (with testdata.dbc - you can use this to utilize VFP9 engine for example, because VFPOLEDB provider is built upon VFP9 engine):
> >
> > Note: With MySQL you would have a different ConnectionString (and SQL may be slightly different but in general rest is same)
> >
> >
Local loRS As ADODB.Recordset, ;
> >   loCon As ADODB.Connection, ;
> >   loCmd As ADODB.Command
> > 
> > loCon = Createobject("ADODB.Connection")
> > loCmd = Createobject('ADODB.Command')
> > loRS  = Createobject("ADODB.RecordSet")
> > With loCon
> >   .ConnectionString = "Provider=VFPOLEDB;Data Source="+_samples+"data\TESTDATA.DBC"
> >   .Mode = 16  && adModeShareDenyNone
> >   .Open()
> > Endwith
> > With loCmd
> >   .ActiveConnection = loCon
> >   .CommandType = 2	&& Table
> >   .CommandText = 'customer'
> > Endwith
> > With loRS
> >   .CursorType 	= 2		&& ADOPENDYNAMIC
> >   .LockType 	= 4		&& ADLOCKBATCHOPTIMISTIC
> >   .CursorLocation = 3		&& ADUSECLIENT
> >   .ActiveConnection = loCon
> >   .Open(loCmd)
> > Endwith
> > 
> > loCon.Execute("set null off")
> > 
> > loRS.AddNew
> > loRS.Fields("Cust_ID").Value = "ADO1"
> > loRS.AddNew
> > loRS.Fields("Cust_ID").Value = "ADO2"
> > loRS.UpdateBatch()
> > loRS.Close()
> > loCon.Close()

> >
> > Cetin Basoz
> >
> > .Net has got better.Think about moving - check my blog:
> > My Blog
> > Blog (mirror) - sounds to be down
>
> Hello Cetin Thanks for your speedy response
>
> More Questions...the conection string is the tricky part for me I can use remote desktop and a VPN to connect to the file server and by extension connect to the mySQL database (OBDC connector and Server IP from the VPN)
> However I want to connect to the database via the internal alone and not throught the a remote desktop connection
>
> I hope that it clear what i want to do...
>
> thanks alot
>
> Chris Smith

With backends like mySQL, MS SQL and such you don't need VPN. In connection string the server might be a URI or TCP/IP address of a server in the other end of world. I don't use mysql but MSSQL. Here are some sample connection strings:

handle = SQLStringConnect("Driver={SQL Server Native Client 10.0};server=www.discountasp.net;database=myDatabase;uid=cetin;pwd=basoz") 


handle = SQLStringConnect("Driver={SQL Server Native Client 10.0};server=190.180.170.160;database=myDatabase;uid=cetin;pwd=basoz") 


It is not a connection to a file server but service (unlike VFP database mysql, mssql ... are service based).

PS: You can for example get hosting from discountasp.net and connect to it as above. I had data there in the past.

Cetin Basoz

.Net has got better.Think about moving - check my blog:
My Blog
Blog (mirror) - sounds to be down

ENTIRE THREAD

updateing a mySQL database Posted by chris smith @ 6/28/2011 4:07:52 PM
RE: updateing a mySQL database Posted by Cetin Basoz @ 6/28/2011 4:45:36 PM
RE: updateing a mySQL database Posted by chris smith @ 6/28/2011 8:14:28 PM
RE: updateing a mySQL database Posted by Cetin Basoz @ 6/28/2011 10:58:08 PM
RE: updateing a mySQL database Posted by chris smith @ 6/29/2011 4:27:06 AM
RE: updateing a mySQL database Posted by Cetin Basoz @ 6/29/2011 7:09:54 PM
RE: updateing a mySQL database Posted by Cody Leaf @ 6/29/2011 7:44:54 PM
RE: updateing a mySQL database Posted by Mike Yearwood @ 6/29/2011 4:36:13 PM
RE: updateing a mySQL database Posted by chris smith @ 6/29/2011 5:34:17 PM