how can connect from asp.net to FoxPro Database  
Author Message
setareh





PostPosted: Visual FoxPro General, how can connect from asp.net to FoxPro Database Top

hi

I have asp.net (with C# ) program and i want connect to FoxPro Database but i dont know how can i do that .

maybe Visual studio 2005 have Provider for it but can't find it .

please help me thank you .



Visual FoxPro1  
 
 
Alex Feldstein





PostPosted: Visual FoxPro General, how can connect from asp.net to FoxPro Database Top

Download the latest OleDB Provider

http://www.microsoft.com/downloads/details.aspx FamilyId=E1A87D8F-2D58-491F-A0FA-95A3289C5FD4&displaylang=en

and look at messages:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=306375&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=8996&SiteID=1


 
 
CetinBasoz





PostPosted: Visual FoxPro General, how can connect from asp.net to FoxPro Database Top

First download VFPOLEDB driver from http://msdn.microsoft.com/vfoxpro/

Then all you need is to use OleDb with VisualFoxpro driver. Here is a very simple sample that I posted before (assuming you have the sample data):



<html>
<script language="C#" runat="server">

Data Source= C:\Program Files\Microsoft Visual FoxPro 9\Samples\Data\testdata.dbc";

void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
OleDbConnection cn = new OleDbConnection();
cn.ConnectionString = strCon;
cn.Open();
OleDbDataAdapter da = new OleDbDataAdapter("select * from customer",cn);
DataSet ds = new DataSet();
da.Fill(ds,"Customer");
cn.Close();

myDataGrid.DataSource = ds;
myDataGrid.DataMember = "Customer";
myDataGrid.DataBind();
}
}
private void GetCustomerOrders(object sender,EventArgs e)
{
OleDbConnection cn = new OleDbConnection();
cn.ConnectionString = strCon;
cn.Open();
string strSelect = String.Format("select * from orders where cust_id = '{0}'",
myTextBox.Text);
OleDbDataAdapter da = new OleDbDataAdapter(strSelect,cn);
DataSet ds = new DataSet();
da.Fill(ds,"orders");
cn.Close();

ordersDataGrid.DataSource = ds;
ordersDataGrid.DataMember = "orders";
ordersDataGrid.DataBind();
}
</script>
<body>
<form runat="server">
Enter customer id:<asp:textbox id="myTextBox" runat="server"/>
<asp:button type="submit" id="cmdGetData" runat="server"
onClick="GetCustomerOrders" Text="Get Customer's Orders"/>
<asp:datagrid id="ordersDataGrid" runat="server"/>
<asp:datagrid id="myDataGrid" runat="server"/>
</form>
</body>
</html>


 
 
setareh





PostPosted: Visual FoxPro General, how can connect from asp.net to FoxPro Database Top

Hi dear alex

thank you , it works .


 
 
setareh





PostPosted: Visual FoxPro General, how can connect from asp.net to FoxPro Database Top

dear CetinBasoz
thank you for your help