CREATE PROCEDURE create_publisher @pub_id char(4), @pub_name varchar(40), @city varchar(20), @state char(2), @country varchar(30) AS /* barebones, not checking for dups */ INSERT INTO publishers (pub_id, pub_name, city, state, country) VALUES (@pub_id, @pub_name, @city, @state, @country) SELECT * FROM publishers WHERE pub_id = @pub_idVFP Code:
* sptest.prg lparameters llUseOleDBProvider, lcPubID * llUseOleDBProvider: pass in .t. to use OLEDB, .f. for ODBC * lcPubID: must be in format of '99xx', and must be unique in publishers table * This is a restriction in the pubs database ? "" ? "Begin..." oConnection = CREATEOBJECT("ADODB.Connection") if llUseOleDBProvider lcConn = "Provider=SQLOLEDB.1;Persist Security Info=False;"+; "User ID=sa;Initial Catalog=pubs;Data Source=orange" else lcConn = "DRIVER={SQL Server};SERVER=orange;database=pubs;uid=sa;pw=" endif oConnection.open(lcConn) oCmd = createObject("adodb.command") with oCmd .commandtype = 4 .activeConnection = oConnection .commandText = 'create_publisher' .parameters("@pub_id") = lcPubId .parameters("@pub_name") = 'Little Bitty Publisher' .parameters("@city") = 'Dallas' .parameters("@state") = 'TX' .parameters("@country") = 'USA' endwith ? "Parameters:" for each opar in ocmd.parameters ? opar.name, opar.value && so far so good... next opar oRs = oCmd.execute && With OLEDB provider, next line fails, and fields collection is empty * ? orS.eof() ? "" ? "Fields contained in recordset:" for each fld in ors.fields ? fld.name,":",fld.value next fld ? "End..."If you put VFP code into sptest.prg, and in command window:
do sptest with .f., '9933' && works great do sptest with .t., '9934' && less filling :)On client, running W2K with the data services that come installed with W2K. On server running W2K Server w/MSDE SQL Server 7.