Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connecting to VFP Data in ASP.NET
Message
 
À
02/05/2006 16:02:54
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
01072118
Message ID:
01118741
Vues:
24
Thanks Cetin, you helped me figure it out. I purposely left out the price field due to a type mismatch that I thought I'd deal with later, turns out that was the problem but fixed it with this line
asp:Parameter Name="price" Type="int32" /.
It's always nice to be able to use native foxpro tables :-)


>>Cetin, I followed your example. I have autogenerateEditButton=TRUE. It goes into edit mode, I make a change to one field,hit UPDATE, but no change is ever written. Am I miussing something do you think? But it does edit the correct record now.
>>
>>
>
>OK here is step by step how I did it. Creata a new project.
>-Drag&dropped an SQLDataSource
>-Clicked configure data source
>< New Connection >
>Data source? Change
>< other >
>.Net Framework provider for ole db
>MS OLEDB provider for VFP
>Server or Filename:C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO 9\SAMPLES\data\testdata.dbc
>Specify a custom SQL or stored procedure
>
>Select:
>SELECT cust_id, company, contact, title FROM customer
>Update:
>UPDATE customer SET company = ?, contact = ?, title = ? WHERE (cust_id = ?)
>
>Finish
>
>-Drag&dropped a gridview
>-Selected SQLDatasource1 from "choose data source" dropdown
>-Enabled paging and editing
>(It sets the DataKeyNames to cust_id automatically - nothing else I did)
>-Run w/o debugging
>
>Here is the full generated code:
>
>
>< %@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" % >
>
><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
><html xmlns="http://www.w3.org/1999/xhtml" >
><head runat="server">
>    <title>Untitled Page</title>
></head>
><body>
>    <form id="form1" runat="server">
>    <div>
>        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
>            ConnectionString="< %$ ConnectionStrings:ConnectionString % >"
>            ProviderName="< %$ ConnectionStrings:ConnectionString.ProviderName % >"
>            SelectCommand="SELECT cust_id, company, contact, title FROM customer"
>            UpdateCommand=
>            "UPDATE customer SET company = ?, contact = ?, title = ? WHERE (cust_id = ?)">
>        </asp:SqlDataSource>
>    </div>
>        <asp:GridView ID="GridView1" runat="server"
>            AllowPaging="True" AutoGenerateColumns="False"
>            DataKeyNames="cust_id" DataSourceID="SqlDataSource1">
>            <Columns>
>                <asp:CommandField ShowEditButton="True" />
>                <asp:BoundField DataField="cust_id" HeaderText="cust_id"
>       ReadOnly="True" SortExpression="cust_id" />
>                <asp:BoundField DataField="company" HeaderText="company"
>      SortExpression="company" />
>                <asp:BoundField DataField="contact" HeaderText="contact"
>      SortExpression="contact" />
>                <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
>            </Columns>
>        </asp:GridView>
>    </form>
></body>
></html>
>
>Cetin
"Build a man a fire, and he's warm for a day.
Set a man on fire, and he's warm for the rest of his life."
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform