Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting a record into a FoxPro's free table using VB.Net
Message
From
19/01/2005 14:33:36
Takashi Koyama
National Indemnity Company
Omaha, Nebraska, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Inserting a record into a FoxPro's free table using VB.Net
Environment versions
Environment:
VB.NET 1.1
OS:
Windows 2000 SP3
Network:
Novell 6.x
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00978657
Message ID:
00978657
Views:
139
Dear developers.....

I develop applications using VFP6.0 and VB.NET.

Currently, I'm developing a VB.NET application and having a difficulty
inserting a record into a FoxPro's free table using VB.Net.

Everything ran smoothly until the program hit the following line in Private Sub update_lwinfile()

objCM.ExecuteNonQuery() '<-- VB.NET doesn't like this.

We use VFP 6.0 so I can only use the ODBC to get to the foxpro free
table. Could you help me on this? Thank you.

Please see the following codes. (Note: I have no problem extracting
data from FoxPro table.)
*****************************************************************
Private Function getMaxKey() As Integer
'This function works, so this is OK

Dim strSQL As String
Dim objCM As Odbc.OdbcCommand
'create the dataset
Dim objDR As Odbc.OdbcDataReader
Dim objDS As DataSet = New DataSet
Dim intMaxKey As Integer
Dim strMaxKey As String

FoxConn.Open()

'sql string to perform
strSQL = "SELECT MAX(NKEY) as MaxNkey FROM lwinfile"

objCM = New Odbc.OdbcCommand(strSQL, FoxConn)
objDR = objCM.ExecuteReader
While objDR.Read
strMaxKey = objDR("MaxNkey")
End While
intMaxKey = Integer.Parse(strMaxKey)

FoxConn.Close()
Return intMaxKey
End Function
*****************************************************************
Private Sub update_lwinfile()

'Everything runs smooth until the end of the program
'ie When the line "objCM.ExecuteNonQuery()" hits

Dim strSQL As String

Dim objCM As Odbc.OdbcCommand
'create the dataset
Dim objDR As Odbc.OdbcDataReader
Dim objDS As DataSet = New DataSet
Dim strProduct As String
Dim strCtype As String
Dim intMaxKey As Integer

intMaxKey = getMaxKey() + 1

FoxConn.Open()

If rbNico.Checked Then
strProduct = "NICO-RATE"
strCtype = "NICORATE"
Else
strProduct = "Garage"
strCtype = "ZGARAGE"
End If

strProduct = strProduct + " for " + cboVersion.Text + " " +
cboCompany.Text
strSQL = "INSERT INTO lwinfile (Ctype, Ctitle, Cdirectory, Cprogram, Cauthority, Nkey) "
strSQL = strSQL + "VALUES ('" + strCtype + "', '" + strProduct
strSQL = strSQL + "','N:\NICO\NICORATE\MN\VERS63', "
strSQL = strSQL + "'MN-ratew.exe', 1, " + intMaxKey.ToString + ")"

objCM = New Odbc.OdbcCommand(strSQL, FoxConn)

objCM.ExecuteNonQuery() '<-- VB.NET doesn't like this.

FoxConn.Close()
End Sub
Next
Reply
Map
View

Click here to load this message in the networking platform