Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connecting to VFP Data in ASP.NET
Message
 
À
04/01/2006 19:48:21
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:
01083979
Vues:
25
Yes, so now you see how it works. I guess there's no more need for code like :
OleDbDataAdapter da = new OleDbDataAdapter(strSelect,cn); ????? becasue the web.config handles that?
I usually blank out the selectcommand="" in the aspx and put it in my VB code behind where I can modify/tweak it more than the wizard allows.
However I tried to implement your "?" example but I got an error
~~ SelectCommand="SELECT company, contact, country FROM customer WHERE (country = ?)"> ~~

>Guess what. I installed VS 2005. Went to create an ASP.net page using VB. You wouldn't believe this. It took me at least 5-10 mins to figure out how to do that:) Reading help didn't help < vbg >: 1st step "Open Visual Web Developer"
>I know that, the problem is where did you hide it!, naturally thought it might not be part of VS IDE now.
>In VS2003, that was easy, just select a language then ASP.net. All is there just where you would like it to be. New start page sucks and hides real info (but that's day 1 with this IDE:).
>Now after that frustration tried to create a sample and suddenly my frustration was replaced with a series of "wow"s:)
>OK new version of sample. Code is in C# (well would be as you might see in page directive),VB,J# ... because there is no code!
>
>
><%@ Page Language="C#" AutoEventWireup="true" %>
>
><!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>
>        Enter a country : 
>        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
>        <br />
>        <asp:GridView ID="GridView1" runat="server" DataSourceID="vfpTestData">
>        </asp:GridView>
>        <asp:SqlDataSource ID="vfpTestData" runat="server" ConnectionString="<%$ ConnectionStrings:vfpTestDataConnection %>"
>            ProviderName="<%$ ConnectionStrings:vfpTestDataConnection.ProviderName %>" SelectCommand="SELECT company, contact, country FROM customer WHERE (country = ?)">
>            <SelectParameters>
>                <asp:ControlParameter ControlID="TextBox1" DefaultValue="" Name="country" PropertyName="Text"
>                    Type="String" />
>            </SelectParameters>
>        </asp:SqlDataSource>
>
>    </div>
>    </form>
></body>
></html>
>
>
>Now since actually almost all was written by "Visual web developer" which I could hardly find here are the steps:
>-Created new project
>-On design surface entered the text "Enter a country :"
>-Dragged a textbox from toolbox
>-Dragged a GridView from toolbox
>-Clicked its little arrow on top right to configure data source
>-Selected "Database" and named it, 'other' and VFPOLEDB etc... for connection part
>-Selected 3 fields above from customer
>-Now the important part:
>
>-Clicked where and selected
>"Country" field,
>"=" operator,
>source as control,
>controlID "TextBox1"
>
>and clicked add.
>
>-Run
>
>Now connectionstring is in web.config file as you said. Notice that how instead of building the whole query string binding it to a parameter works. Save this as an aspx and create a web.config file with connectionstring in it. Here is mine (comments etc stripped):
>
><?xml version="1.0"?>
><configuration>
>	<connectionStrings>
>		<add name="vfpTestDataConnection" connectionString="Provider=VFPOLEDB.1;Data Source="C:\Program Files\Microsoft Visual FoxPro 9\Samples\Data\testdata.dbc"" providerName="System.Data.OleDb"/>
>	</connectionStrings>
></configuration>
>
>
>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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform