473,320 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using Databases

Hi,
I'm making a program which accepts orders in a restaurant, and it is linked to a database. I'm using VB .NET.

I have a couple of things I can't find out how to do, so if someone could tell me simply how to do them it would be great.

The first thing is, is it possible to delete all the records from a database when the program initialises? How do I do it?

I would also like to know if it is possible to display items from the database in a listbox, or is it just simpler to use a datagrid.

In my program there is an order list which displays all orders in a datagrid. Once the order has been served, you are supposed to be able to press "Order Served"(Button), which then sets a "Served" Boolean value to true. This keeps the record in the database, however it removes the record from the datagrid.

The Data adapter is called daOrders, the data structure is called TableOrdersDS1.

Thanks!
Sep 3 '06 #1
6 1784
izzy
12
Hi,
I'm making a program which accepts orders in a restaurant, and it is linked to a database. I'm using VB .NET.
What kind of database? I assume Access?? You can use a DDL SQL query to create the structure of the database the first time it runs. I am not 100% this works with access, but I do not see why not.
Sep 3 '06 #2
first thing, If you are using SQL Server
try it:
(the code is in C#, but you can easily change it to VB, its easy!!!)
private void Form1_Load(object sender, EventArgs e)
{
SqlConnection myconnection = new SqlConnection("Data Source=<myDBServer>;Initial Catalog=<MyDB>;Integrated Security=True");
SqlCommand com = new SqlCommand("Delete from <MyTable>", myconnection);
try
{
myconnection.Open();
com.ExecuteNonQuery();
}
catch (Exception)
{
throw;
}
finally
{
myconnection.Close();
}

}
code into <> means that you must change it into your names.
Sep 4 '06 #3
nmsreddi
366 256MB
hi

The questions which you have raised is very thing possible they are very common things in every project. irrespective of language you are using (vb or c#)
It is better to go using data grid if your database changes randomly else you can choose any other control like list box.

next thing is you can display data on to datagrid on pageload or when ever it is required

try it out if you are in need code try posting again with particular requirement but not as hole project please..

rergards

nmsreddi
Sep 4 '06 #4
Hi, thanks for your responses, and I tried to convert the C# to vb .net and it didnt work. If anyone could put it in VB .NET that would be greatly appreciated.

And what is the method you would use to display the rows in a listbox?

Thankyou
Sep 4 '06 #5
Also, if I wanted to add up the "Price" columns in all records, how would I move through all the records, storing each read field each time through a loop.
Sep 4 '06 #6
One more thing, its throwing "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll" when it executes the following code:
m_DataSet.Tables("Orders").Rows(1).Item("Served") = True
m_DataAdapter.Update(m_DataSet, "Orders")

What is the cause of this problem and how can i fix it?
Sep 5 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Cara | last post by:
LAST CALL FOR VOTES (of 2) unmoderated group comp.databases.etl Newsgroups line: comp.databases.etl Extraction, transformation, loading issues. Votes must be received by 23:59:59 UTC, 12 Dec...
1
by: Sandie Towers | last post by:
We use a number of similar databases and frequently create a new database using a backup restore of another similar database. We try to keep changes between databases in _Additional tables - like...
0
by: Cara Altman | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.databases.etl This is a formal Request For Discussion (RFD) for the creation of a world-wide unmoderated Usenet newsgroup...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
2
by: John Dann | last post by:
Apologies if this isn't the best group - maybe someone can suggest a more appropriate one - I can't immediately see anything on ado.net. I need to store a significant amount of data (say 1-10MB)...
14
by: ml_sauls | last post by:
I've built a system to enter and manage purchase orders. This is in use by >10 clients. Some use it in Access 97, most are in A2k. About half use it through a Citrix implementation. It is...
3
by: Erik Lautier | last post by:
I have a content site where everything is currently in one SQL Server DB. As I add features to the site, for example message boards and blogging, does it make sense to put those features in a...
0
by: David | last post by:
- Are there any peculiarities with using curs.executemany(...) vs. multiple How many times are you calling execute vs a single executemany? The python call overhead will add up for thousands of...
4
by: sganeshsvk | last post by:
sir, i want to store the same data values in two different databases at that same time in mysql using php programming. suppose any one databases data will lose then we use the other...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.