Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting into Foxpro date field
Message
From
17/01/2007 01:54:49
 
 
To
16/01/2007 23:55:07
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01185949
Message ID:
01186150
Views:
33
hmmmm....
thanks.

Is there a book I can readup on this matter to get more detail. None of the my C# books say anything about this. And the web is not much help either.


>>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.
The American Republic will endure, until politicians realize they can bribe the people with their own money.
- Alexis de Tocqueville

No man’s life, liberty, or property is safe while the legislature is in session.
– Mark Twain (1866)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform