Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting into Foxpro date field
Message
From
16/01/2007 23:55:07
 
 
To
16/01/2007 23:45:58
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01185949
Message ID:
01186146
Views:
27
>Either way it won't go into a foxpro DATE field. However, they can both go into foxpro Character field.

I wouldn't recommend to put your values as is inside your SQL. All values in a SQL command should be parameterized. Also, if you do this like that, you will never have to worry about adjusting accordingly to the type of the field. Using that, you will also avoid SQL hijacking.

Here is an example of how I do it. Basically, all parameters are inserted at first and then I do the SQL command:
            loDataProvider.ParameterAdd("Numero", oProcess.nNoMember)
            loDataProvider.ParameterAdd("Session3", oProcess.cSession2)
            If Not loDataProvider.SQLExec("SELECT Member.Numero " + _
             "FROM Member " + _
             "WHERE Member.Numero=" + loDataProvider.ParameterAddSQL("Numero") + " AND " + _
             "Member.Session3=" + loDataProvider.ParameterAddSQL("Session3")) Then
                Return False
            End If
This one uses a data class I have. But, basically, if you code it entirely, you will follow the same route such as:
        Public oDataSet As DataSet
        Public oDataTable As DataTable
        Public oDataView As DataView
        Public oParameters As New ArrayList
        Private oDataParameter As IDbDataParameter = Nothing
        Private oCommand As IDbCommand = Nothing
        Private oCommandText As New Collection
        Private oDataAdapter As IDbDataAdapter = Nothing
        Private oDataParameter As IDbDataParameter = Nothing
        Private oDataReader As IDataReader = Nothing
        Private oParameters2 As New Collection

                        oDataParameter = New OleDbParameter("@Numero", oProcess.nNoMember)
                        oParameters2.Add(oDataParameter)
                        oDataParameter = New OleDbParameter("@Session3", oProcess.cSession2)
                        oParameters2.Add(oDataParameter)

                oCommand.CommandText = tcSQL

                ' Only add the parameters if we have some
                If oParameters2.Count > 0 Then
                    For Each oDataParameter In oParameters2
                        oCommand.Parameters.Add(oDataParameter)
                    Next
                End If

                oDataAdapter.SelectCommand = oCommand
                oDataSet = New DataSet

                ' By default, .NET does not add the specific field length, which is needed in XML as at the other end
                ' someone would always get memo field instead of character field
                oDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

                oDataAdapter.Fill(oDataSet)

                ' If we have a command text
                If oCommandText.Count > 0 Then

                    ' Clear the command text collection
                    oCommandText.Clear()

                End If

                ' Adjust to our default name
                oDataSet.Tables("Table").TableName = "Temp"

                ' Record count
                nCount = oDataSet.Tables("Temp").Rows.Count

                ' If we have at least one record
                If nCount > 0 Then
                    oDataView = New DataView
                    oDataView = oDataSet.Tables("Temp").DefaultView
                End If

                oCommand.Dispose()
Note that code is just to show you an example. It is not a workable code. So, you may have to adjust. But, this should give you a good idea.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform