Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ASP says not a table
Message
De
05/12/2007 16:44:00
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
05/12/2007 12:30:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01252602
Message ID:
01273454
Vues:
21
>
>>>>if ( lcTIP_id = String.Empty )
>>>>
>>>>Cetin
>>>Thanks
>>>I would have expected that VB would be supported in .NET.
>>>So, if I work in .NET what language will I be using?
>>>- Don
>>
>>I'm using C#. You can choose that too or something else like VB.Net (or some other .Net language).
>>Cetin
>
>Cetin -
>Assuming I'm working with .NET VB, can you tell me how to establish the connection to a VFP database and assign a table field to a textbox? I can do it with traditional ASP code but can't seem to find the trick with the .NET system. I tried to setup a database connection with the database explorer. It shows the tables but will not expand them. And then what else goes here?
>
>
><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
>
>
>I assume this is just a syntax thing.
>
>Thanks

Don,
Here is a step by step process for a simple aspx page (you can check the source view for binding syntax) - posted before to foxite:

-File\New\Web site\ASP.Net web site under C# category and name it SimpleVFP (in VWD web site may not exist as it always builds web sites)

-You get default.aspx in design (design HTML source) mode. Switch to design clicking "Design" tab on bottom.

-From toolbox\data section drag&drop "DataGridView" on to page surface. It shows common tasks for a datagrid automatically.

-Drop down data source combo and select "< New data source >". From popup window select "Database" (rename source if you want to). Click ok.

-Click 'New connection'. Add connection dialog pops up. Data source: Click 'Change' and select '< other >' from data source listbox, and '.Net framework data provider for OLEDB' from data provider combo.

-Upon returnin to 'Add connection', select 'MS Ole DB provider for Visual Foxpro' as the provider. Type fullpath for testdata.dbc for 'server or filename'. ie:

C:\Program Files\Microsoft Visual Studio\MSDN\2001OCT\1033\SAMPLES\VFP98\data\testdata.dbc

and click 'Test connection' to verify the connection. Once verified, click OK.

-Click 'Next' and again 'Next' ('Yes save this connection as' checked, change name if you want to). Now you're at configuration step.

-With second option selected you see 'Customer' in combo and its fields. Select * and it writes:

select * from [customer]

in SQL window. Click 'Advanced' and check 'Generate insert/update/delete statements'. Click ok and finish.

-Now you have the grid with fieldnames populated. Check 'enable' series 'Sorting,paging,editing,deleting'.
-Click anywhere on page (we are done with that one).
-Now you have a grid + an SQLDataSource object on page. Click on SQLDataSource.
-Go to its properties window. Select "DeleteQuery". It says (Query) and have a comman button on the right with '...' as caption. Click it. It shows the command it'd execute. You'd notice it wrapped both the tablename and fieldnames with brackets. Remove the brackets from field name(s):

Old:

DELETE FROM [customer] WHERE [cust_id] = ?


New:

DELETE FROM [customer] WHERE cust_id = ?



That's because if you don't remove the brackets VFP interprets [cust_id] as a literal string rather than a fieldname. Do the same for InsertQuery, UpdateQuery (and SelectQuery if you didn't use * but specified fieldnames).

Congratulations. You have finished a very simple ASP.Net page. Run it clicking green ' > ' icon or pressing F5. It'd popup a message, yes and go.

Edit, Delete as you wish and check from VFP:) After deleting a few, you may recall them from VFP and refresh the asp.net page clicking one the headers to sort or move to another page.

Adding a login form (based on usernames and passwords from your VFP data-if you want it that way), using Details/Form view instead or in conjuction (like a VFP detail form with Prev/Next/Add/Edit/Delete buttons) etc are similarly easy. Notice that we didn't write a single line of code yet:) Deployment is easy too and VS2005 have tools in it for the job, I think VWD too has. If not it's almost DOS copy with few manual arrangements in IIS configuration.

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