×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hi All, Can you help me, when I
2

Hi All, Can you help me, when I

Hi All, Can you help me, when I

(OP)
Hi All,

Can you help me, when I run my program from visual foxpro and updating the data records from browse windows unable to send update to sql table(backend). my requirements should be automatic update the records to sql table/backend.
below is my program. can you assist me what I missed the commands/scripts.

hConn=("Driver=SQL Server;DSN=GHIESOURCE;Server=DESKTOP-KAH179Q;UID=;PWD=;DATABASE=MASTER")
nHandle=SQLSTRINGCONNECT(hConn)
?nHandle
SQLEXEC(nHandle,"SELECT * FROM DBO.MSreplication_options","tblMScursor")
set multilocks on
BROWSE && from this Im doing update/editing data records that should be sent to sql table backend.
=CURSORSETPROP("Buffering", 5, "tblMScursor")
=CURSORSETPROP("tables","dbo.MSreplication_options","tblMScursor")
=CURSORSETPROP("KeyFieldList","Id","tblMScursor") && Id is the name of the primary key
=CURSORSETPROP('UpdateFieldList', 'optname, major_version, minor_version, revision, install_failures, Id', 'tblMScursor')
=CURSORSETPROP("UpdateNameList", "optname optname","value value","major_version major_version","minor_version","revision revision","install_failures install_failures","Id Id", "tblMScursor")
=CURSORSETPROP("sendupdates",.t., "tblMScursor")
SELECT tblMScursor
TABLEUPDATE(2,.T.,"tblMScursor")
BROWSE
CLOSE ALL

RE: Hi All, Can you help me, when I

2
You seem to be setting the correct properties, but where are you actually doing the updates? Are you doing them interactively in the first Browse? If so, that's too early. You need to set the properties before you do the updates.

Or are you doing them interactively in the second Browse? If so, you need to do the TABLEUPDATE() after you do the updates.

You might also want to consider a simpler way of updating the back-end table. Instead of making the cursor updatable, you could construct an UPDATE statement, then send it to the back-end via SQLEXEC().

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Hi All, Can you help me, when I

yes mike im doing update/append on the first browse and I want the records send upate to sql table/backend but didn't affect on the sql table.

RE: Hi All, Can you help me, when I

Then you should do the updates after your calls to CURSORSETPROP() and before your call to TABLEUPDATE().

It's also useful to test the value returned from TABLEUPDATE(). If it reurns .F., call AERROR() to determine the error.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Hi All, Can you help me, when I

(OP)
is this possible to use simple 1st browse command to edit/insert records then to follow setcursor.

RE: Hi All, Can you help me, when I

No. You must set the cursor properties before you do any updates. In most cases, you would set the cursor properties once only, once you have rerieved the cursor from the back end. You then do the updates, as many as you need, either interactively or programmatically. And finally you call TABLEUPDATE() to send the updates to the back end.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Hi All, Can you help me, when I

(OP)
can you give me sample cursor properties that needs to put on the script before doing updates and send new updated data records into the backend/sql table.
can you correct the sequence of the ff. script below.

=CURSORSETPROP("Buffering", 5, "tblMScursor")
=CURSORSETPROP("tables","dbo.MSreplication_options","tblMScursor")
=CURSORSETPROP("KeyFieldList","Id","tblMScursor") && Id is the name of the primary key
BROWSE && doing update/editing data records

=CURSORSETPROP('UpdateFieldList', 'optname, major_version, minor_version, revision, install_failures, Id', 'tblMScursor')
=CURSORSETPROP("UpdateNameList", "optname optname","value value","major_version major_version","minor_version","revision revision","install_failures install_failures","Id Id", "tblMScursor")
=CURSORSETPROP("sendupdates",.t., "tblMScursor")
SELECT tblMScursor
TABLEUPDATE(.T.,"tblMScursor")

thanks your help response is highly appreciated. thanks

RE: Hi All, Can you help me, when I

At first glance, it looks like you've got all the correct settings, but in the wrong order. This is what you need:

CODE -->

=CURSORSETPROP("Buffering", 5, "tblMScursor")
=CURSORSETPROP("tables","dbo.MSreplication_options","tblMScursor")
=CURSORSETPROP("KeyFieldList","Id","tblMScursor") && Id is the name of the primary key
=CURSORSETPROP('UpdateFieldList', 'optname, major_version, minor_version,;
   revision, install_failures, Id', 'tblMScursor')
=CURSORSETPROP("UpdateNameList", "optname optname","value value","major_version major_version",;
  "minor_version","revision revision","install_failures install_failures","Id Id", "tblMScursor")
=CURSORSETPROP("sendupdates",.t., "tblMScursor")

SELECT tblMScursor
BROWSE && doing update/editing data records
TABLEUPDATE(.T.,"tblMScursor") 

Also, you only need to do the CURSORSETPROPs once - any time after you have obtained tblMScursor). You don't need to do them every time you do the Browse.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close