PROCEDURE AddRespArch( theNewID AS INTEGER, ; tPatID AS INTEGER, ; tRespDate AS DATETIME, ; tXml as String,; tSignature as String,; tIsSignatureHexEncoded as Boolean) LOCAL newresparchid AS INTEGER LOCAL lSignature as String lSignature = IIF( m.tIsSignatureHexEncoded, ; STRCONV(m.tSignature,16), ; m.tSignature) newresparchid = m.theNewID *newresparchid = NewID('RespArch','iresparchid') INSERT INTO RespArch ; ( ; iresparchid, ; ipatientid, ; tresponse, ; xml, ; bsignature ; ) ; VALUES ; ( ; m.newresparchid, ; m.tPatID, ; m.tRespDate, ; m.tXml, ; m.lSignature ; ) theNewID = newresparchid RETURN theNewID && GetNewIDResSet(theNewID) ENDPROCAnd .Net test:
using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.OleDb; using System.IO; namespace VFPSpCall { class Program { static void Main(string[] args) { string strCon = @"Provider=VFPOLEDB;Data Source=c:\temp\NetSample.dbc"; string[] fileNames = new string[] { @"c:\temp\graphics\suyamich.gif", @"c:\temp\graphics\buchstev.gif", @"c:\temp\graphics\davonanc.gif", @"c:\temp\graphics\dodsanne.gif", @"c:\temp\graphics\fullandr.gif" }; OleDbConnection cn = new OleDbConnection(strCon); // Prepare command and parameters OleDbCommand cmd = new OleDbCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "AddRespArch"; cmd.Connection = cn; OleDbParameter p1 = cmd.Parameters.Add("theNewID", OleDbType.Integer); OleDbParameter p2 = cmd.Parameters.Add("tPatID", OleDbType.Integer); OleDbParameter p3 = cmd.Parameters.Add("tRespDate", OleDbType.Date); OleDbParameter p4 = cmd.Parameters.Add("tXML", OleDbType.Char); OleDbParameter p5 = cmd.Parameters.Add("tSignature", OleDbType.PropVariant); OleDbParameter p6 = cmd.Parameters.Add("tSignatureHexEncoded", OleDbType.Boolean); p6.Value = true; cn.Open(); // insert 5 records for (int i = 0; i < 5; i++) { byte[] image = File.ReadAllBytes(fileNames[i]); Console.WriteLine(image.Length); p1.Value = i; p2.Value = i * 10; p3.Value = DateTime.Now.AddDays(-i); p4.Value = String.Format("<SomeTag>SomeValue {0}</SomeTag>", i); p5.Value = BitConverter.ToString(image).Replace("-",String.Empty); int retValue = (int)cmd.ExecuteScalar(); Console.WriteLine("Inserted record with ID: {0}", retValue); } cn.Close(); } } }Cetin
>PROCEDURE AddRespArch >LPARAMETERS theNewID AS INTEGER, ; > tPatID AS INTEGER, ; > tRespDate AS DATETIME, ; > tXml as String, ; > tSignature as Image > >LOCAL newresparchid AS INTEGER > >NewID('RespArch','iresparchid',1,@newresparchid) > > INSERT INTO RespArch ; > ( ; > iresparchid, ; > ipatientid, ; > tresponse, ; > xml, ; > bsignature ; > ) ; > VALUES ; > ( ; > newresparchid, ; > tPatID, ; > tRespDate, ; > tXml, ; > tSignature ; > ) > theNewID = newresparchid > RETURN GetNewIDResSet(theNewID) >ENDPROC >>