Re: I want to create a database and store and retrieve information



Hi Bob,

Yes Foxpro does have SQL but I never did use it myself.

Thanks very helpful. It seems like you really have to do a lot of work just
to add a record in a table. In Foxpro it is so much easier as you do it all
in one statement with ease. :)

Roy



"Bob Powell [MVP]" <bob@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:elw3EKc0FHA.3660@xxxxxxxxxxxxxxxxxxxxxxx
> VS has a developer version of SQL server which is OK for developing apps
> that you can test out.
>
> Storing and retrieving data is as simple ad writing the SQL statements
> that manipulate the tables. I don't know anything about FoxPro so, to be
> honest, I don't even know if it does SQL.
>
> Because I'm a cheapskate I often use access databases or MySQL. SQL server
> is really an option for a company that can afford the license fees. It's
> by far the best choice but one needs to be committed to a certain level of
> monetary outlay.
>
> Here for example is a simple set of commands I used to populate a repeater
> on a website I did a while back. It uses Access...
>
> DataSet ds=new DataSet();
>
> OleDbConnection cnx=new
> OleDbConnection(Constants.ConnectionString(this.Server));
>
> OleDbDataAdapter da=new OleDbDataAdapter("SELECT * FROM content",cnx);
>
> da.Fill(ds);
>
> this.Repeater1.DataSource=ds;
>
> this.Repeater1.DataBind();
>
> That was a pretty simple one. The Constants class just lets me get a
> connection string according to whether i'm in debug mode so the connection
> string points to my local access database file or in release mode in which
> case it uses Server.MapPath to get to where my DB is stored.
>
> Here's me adding a record to a table...
>
> cmd=new OleDbCommand("INSERT INTO products(product_name, stock, minstock,
> price, content, category, description) VALUES(?,?,?,?,?,?,?);",cnx);
>
> cmd.Parameters.Add("product_name",OleDbType.Char).Value=this.name.Text;
>
> cmd.Parameters.Add("stock",OleDbType.Integer).Value=int.Parse(this.stock.Text);
>
> cmd.Parameters.Add("minstock",OleDbType.Integer).Value=int.Parse(this.minstock.Text);
>
> cmd.Parameters.Add("price",OleDbType.Currency).Value=decimal.Parse(this.price.Text);
>
> cmd.Parameters.Add("content",OleDbType.Integer).Value=content;
>
> cmd.Parameters.Add("category",OleDbType.Integer).Value=int.Parse(this.DropDownList1.SelectedValue.ToString());
>
> cmd.Parameters.Add("description",OleDbType.Integer).Value=description;
>
> cmd.ExecuteNonQuery();
>
> and here's me updating a table with some changed data...
>
> OleDbCommand cmd=new OleDbCommand("UPDATE products SET product_name=?,
> stock=?, minstock=?, price=?, content=?, category=?, description=? WHERE
> productid=[i];",cnx);
>
> cmd.Parameters.Add("product_name",OleDbType.Char).Value=this.name.Text;
>
> cmd.Parameters.Add("stock",OleDbType.Integer).Value=int.Parse(this.stock.Text);
>
> cmd.Parameters.Add("minstock",OleDbType.Integer).Value=int.Parse(this.minstock.Text);
>
> cmd.Parameters.Add("price",OleDbType.Currency).Value=decimal.Parse(this.price.Text);
>
> cmd.Parameters.Add("content",OleDbType.Integer).Value=(int)ViewState["content"];
>
> cmd.Parameters.Add("category",OleDbType.Integer).Value=this.DropDownList1.SelectedValue;
>
> cmd.Parameters.Add("description",OleDbType.Integer).Value=ViewState["description"];
>
> cmd.Parameters.Add("i",OleDbType.Integer).Value=item;
>
> cmd.ExecuteNonQuery();
>
>
>
> As you can see it's all pretty straightforward. Even I can manage it :-)
>
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Ramuseco Limited .NET consulting
> http://www.ramuseco.com
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> "Roy Gourgi" <royng@xxxxxxxxxxxx> wrote in message
> news:Oi94f.17374$HQ3.508912@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi,
>>
>> Thanks for replying.
>>
>> I think I will break ties with FoxPro and COM and go for either SQLServer
>> or Access. There seems to be a lot more support for SQLServer than
>> Access, so I think that I will try SQLServer. What do I have to do to get
>> SQLServer and which version should I be using. Or is SQLServer already
>> part of the VS.Net?
>>
>> All I really need is to store and retrieve information from a database.
>> What do you recommend and are there any examples?
>>
>> TIA
>> Roy
>>
>>
>> "Bob Powell [MVP]" <bob@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:u6OYXQX0FHA.3956@xxxxxxxxxxxxxxxxxxxxxxx
>>> Hello,
>>> There are many possibilities. You can use SQLServer or Access, If you
>>> want to go cheap there are alternatives such as MySQL that have C# or
>>> Visual Basic wrappers.
>>>
>>> Probably more attractive to you is the fact that VFP can be automated
>>> via COM. Therefore you can write VB or C# applications that use the
>>> database engine you're most familiar with.
>>>
>>> You'd really be petter asking these questions over in a VFP group I
>>> guess.
>>>
>>> Oh... have you seen this??
>>> http://foxcentral.net/microsoft/NETforVFPDevelopers.htm
>>>
>>> --
>>> Bob Powell [MVP]
>>> Visual C#, System.Drawing
>>>
>>> Ramuseco Limited .NET consulting
>>> http://www.ramuseco.com
>>>
>>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>>> http://www.bobpowell.net/tipstricks.htm
>>>
>>> Answer those GDI+ questions with the GDI+ FAQ
>>> http://www.bobpowell.net/faqmain.htm
>>>
>>> All new articles provide code in C# and VB.NET.
>>> Subscribe to the RSS feeds provided and never miss a new article.
>>>
>>>
>>>
>>>
>>>
>>> "Roy Gourgi" <royng@xxxxxxxxxxxx> wrote in message
>>> news:ec04f.26009$Tn2.585304@xxxxxxxxxxxxxxxxxxxxxx
>>>> Hi,
>>>>
>>>> I am used to working in Visual FoxPro and I would like to be able to
>>>> create a database and store and retrieve information from it. What is
>>>> the simplest way to do it and what should I be using as there are many
>>>> choices to choose from.
>>>>
>>>> My database will contain a lot of records.
>>>>
>>>> TIA
>>>> Roy
>>>>
>>>
>>>
>>
>>
>
>


.



Relevant Pages

  • Re: I want to create a database and store and retrieve information
    ... There seems to be a lot more support for SQLServer than Access, ... All I really need is to store and retrieve information from a database. ... > Find great Windows Forms articles in Windows Forms Tips and Tricks ... >> I am used to working in Visual FoxPro and I would like to be able to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Optimizing remote views to SQL 2k
    ... now what I have to do is convert an existing foxpro application that I ... learn foxpro / dbf and use my SQL knowledge to optimize it! ... but it took me 2 weeks to find how to open a database in foxpro!! ... Look up "Parameterized Remote Views" in the help file. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Anzahl der in einem Grid angezeigten Datensätze
    ... Dann brauchste erst garnicht mit FoxPro zu arbeiten und kannst gleich zu VB ... Aber genauso lassen sich manche xBase SCAN ... Schleifen mit nem Einzeiler in SQL darstellen. ... egal ob das gerade eben der technologisch Neueste Schrei ist. ...
    (microsoft.public.de.fox)
  • Re: Insert, Udate, Select data with embedded C++
    ... Definitely read Joao's excellent articles on codeproject and PocketPCdn. ... wrapper to SQL CE for Sql Mobile and am almost done. ... > Does anyone know where I can find some useful information (preferably ...
    (microsoft.public.sqlserver.ce)
  • Re: MS SQL 2005 Configuration ???
    ... It sounds like you are running SQLExpress, not SQLServer. ... I don't have SQL Express, so I can't replicate what you're seeing. ... "Surface Area Configuration for Services and Connections", ... SQL Server Browser). ...
    (microsoft.public.dotnet.framework.adonet)