Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling an Update Stored Procedure.
Message
General information
Forum:
ASP.NET
Category:
Visual FoxPro Toolkit for .NET
Miscellaneous
Thread ID:
00674696
Message ID:
00674776
Views:
26
Where you call SQLExecute(), replace that line with the following:

oconn.Open()
oCommand.ExecuteNonQuery()

>So then the question is, "How can I send updates to the Database?"
>
>
>
>>You need to pass a select statement to the Toolkit's SQLExecute function. It then returns a filled DataView. This function is not intended to pass an Update statement. This is being considered to be revised for a future update to the toolkit.
>>
>>>Here is the code.
>>>
>>>********* Save Routine *****
>>> ' Set up connection and command
>>> Dim oconn As System.Data.OleDb.OleDbConnection
>>> Dim oCommand As New OleDbCommand()
>>>
>>> ' passing parameter to stored procedure
>>> ' I have tried both Char and VarChar for OLEdb
>>> Dim oparam1 As New OleDbParameter("@cssn", OleDb.OleDbType.VarChar)
>>>
>>> ' gcpuem is a memvar which contains the connectin string
>>> oconn = SqlConnect(gcPuem)
>>>
>>> oCommand.CommandType = CommandType.StoredProcedure
>>>
>>> ' _TestUpdate is the SP being called, code is below.
>>> oCommand.CommandText = "_TestUpdate"
>>>
>>> oCommand.Parameters.Clear()
>>> 'storing employee ssn, value is 000110000
>>> oparam1.Value = Me.txtcssn.ClipText
>>> oCommand.Parameters.Add(oparam1)
>>>
>>> ' Bug in ToolKit, should be fixed in future release but need this
>>> ' code for now.
>>> oCommand.Connection = oconn
>>>
>>> ' Tried both of the following lines with the same results.
>>> ' gvEmployee = SqlExecute(oconn, oCommand) ', "curEmployee")
>>> SqlExecute(oconn, oCommand)
>>>
>>> ' Close the connection
>>> SqlDisConnect(oconn)
>>>
>>>
>>>*** Stored Procedure Code ***
>>>
>>>CREATE PROCEDURE _TestUpdate
>>>' Test SP only!
>>>@cssn as char(9)
>>>
>>>AS
>>>
>>>update pclaim set cssn = @cssn where pid = 2
>>>GO
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform