11 Replies - 1392 Views - Last Post: 02 March 2011 - 07:13 PM Rate Topic: -----

#1 omgemoako  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 10-September 09

VB.NET-FOXPRO query problem

Posted 02 March 2011 - 12:57 AM

hi I'm working on a project which includes connection to a foxpro database. My problem is when I query a command which has a condition it's not working but it is working in foxpro 7.0. It only works if I don't assign a condition.
here is my code please help me.. thanks..



 Dim conFoxpro As New OleDbConnection("provider=provider;Data Source=path;Collating Sequence = general") 'Create a new Foxpro connection
        Dim cmdFoxpro As New OleDbCommand("Select * from pe_civil_status WHERE DELETED() and date_updt >= {^" & min_date_update.Year & "-" & min_date_update.Month & "-" & min_date_update.Day & " " & min_date_update.Hour & ":" & min_date_update.Minute & ":" & min_date_update.Second & "}", conFoxpro)
        MsgBox("Select * from pe_civil_status WHERE DELETED() and date_updt >= {^" & min_date_update.Year & "-" & min_date_update.Month & "-" & min_date_update.Day & " " & min_date_update.Hour & ":" & min_date_update.Minute & ":" & min_date_update.Second & "}")
        Dim daFoxpro As New OleDbDataAdapter
        Dim dsFoxpro As New DataSet
        Try
            conFoxpro.Open()
            daFoxpro.SelectCommand = cmdFoxpro
            daFoxpro.SelectCommand.ExecuteNonQuery()
            daFoxpro.Fill(dsFoxpro, "pe_civil_status")
            dgMysql.DataSource = dsFoxpro.Tables("pe_civil_status")
            MsgBox(dsFoxpro.Tables("pe_civil_status").Rows.Count)
        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            conFoxpro.Close()
            conFoxpro.Dispose()
            cmdFoxpro.Dispose()
            daFoxpro.Dispose()
            daFoxpro.Dispose()
            dsFoxpro.Dispose()
        End Try


Is This A Good Question/Topic? 0
  • +

Replies To: VB.NET-FOXPRO query problem

#2 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,917
  • Joined: 25-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 05:23 AM

Your connection string doesn't look right. I'm assuming Provider and Path are variables that hold the actual provider string and path string. These will need to be concatenated in or use string.format to incorporate their actual strings.
something like:
Dim constr As String = String.Format("provider = {0};Data Source={1};Collating Sequence= general", provider, path)
Dim conFoxpro As New OleDbConnection(constr)

This post has been edited by CharlieMay: 02 March 2011 - 05:24 AM

Was This Post Helpful? 0
  • +
  • -

#3 omgemoako  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 10-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 05:16 PM

View PostCharlieMay, on 02 March 2011 - 12:23 PM, said:

Your connection string doesn't look right. I'm assuming Provider and Path are variables that hold the actual provider string and path string. These will need to be concatenated in or use string.format to incorporate their actual strings.
something like:
Dim constr As String = String.Format("provider = {0};Data Source={1};Collating Sequence= general", provider, path)
Dim conFoxpro As New OleDbConnection(constr)


Thanks for the response.. This is my connection string used: Dim conFoxpro As New OleDbConnection("Provider=vfpoledb;Data Source=D:\Production\Data\;Collating Sequence=general").. I really don't figure out what's wrong.. bfft..
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,917
  • Joined: 25-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 05:37 PM

Shouldn't there be a filename after Data\ ?

Check Out ConnectionStrings.Com for help with connectionstrings. I'll see what I can find when I get back.
Was This Post Helpful? 0
  • +
  • -

#5 omgemoako  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 10-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 05:51 PM

View PostCharlieMay, on 03 March 2011 - 12:37 AM, said:

Shouldn't there be a filename after Data\ ?

Check Out ConnectionStrings.Com for help with connectionstrings. I'll see what I can find when I get back.


I have tried adding the name of the table< Dim conFoxpro As New OleDbConnection("Provider=vfpoledb;Data Source=D:\Production\Data\pe_civil_status.dbc;Collating Sequence=general;Exclusive=No;Deleted=True") 'Create a new Foxpro connection> but it prompts me an error: "Invalid path or file name. at System.Data.OleDbConnectionInternal.ctor(OleDbconnectiontionString constr, OleDbConnection connection)"
I'm sure I have put the correct name of the table.. :(
Was This Post Helpful? 0
  • +
  • -

#6 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,917
  • Joined: 25-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 06:22 PM

Double check the path. Go into you d drive and make sure you have a folder named Production. Then go into production and make sure a folder called Data is there and last of all. Double-Click on Data and make sure that pe_civil_status.dbc is in it.

The error is saying that is either isn't finding that file (pe_civil_status.dbc) in that path or that full path does not exist.
Was This Post Helpful? 0
  • +
  • -

#7 omgemoako  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 10-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 06:29 PM

View PostCharlieMay, on 03 March 2011 - 01:22 AM, said:

Double check the path. Go into you d drive and make sure you have a folder named Production. Then go into production and make sure a folder called Data is there and last of all. Double-Click on Data and make sure that pe_civil_status.dbc is in it.

The error is saying that is either isn't finding that file (pe_civil_status.dbc) in that path or that full path does not exist.

Yes I'm very sure of that.. I'm having a hard time.. :(
Was This Post Helpful? 0
  • +
  • -

#8 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,917
  • Joined: 25-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 06:31 PM

OK, that is .DBF not .DBC. Have you tried D:\Production\Data\pe_civil_status.dbf in your connectionstring?
Was This Post Helpful? 0
  • +
  • -

#9 omgemoako  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 10-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 06:53 PM

View PostCharlieMay, on 03 March 2011 - 01:31 AM, said:

OK, that is .DBF not .DBC. Have you tried D:\Production\Data\pe_civil_status.dbf in your connectionstring?


Yes I have tried that. It still don't work.. Do you think Deleted=True and Exclusive=No in my connection string are valid?
Was This Post Helpful? 0
  • +
  • -

#10 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,917
  • Joined: 25-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 06:59 PM

Do you have any .DBC file in that folder?
Was This Post Helpful? 0
  • +
  • -

#11 omgemoako  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 10-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 07:06 PM

View PostCharlieMay, on 03 March 2011 - 01:59 AM, said:

Do you have any .DBC file in that folder?

do you mean any other .dbc file in my source path? Yes I have.
Was This Post Helpful? 0
  • +
  • -

#12 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,917
  • Joined: 25-September 09

Re: VB.NET-FOXPRO query problem

Posted 02 March 2011 - 07:13 PM

OK, from what I've just read. The .DBC is a database container meaning you have a database. The DBF is a Free File of the table but can be accessed with the .DBC

So does the .DBC contain the pe_civil.status.dbf file?

If so, then that is the file you need to specify in your string.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1