Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connecting to VFP Data in ASP.NET
Message
De
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:
01118547
Vues:
27
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform