home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2856
Discussions: 186,668, Posts: 2,227,696, Members: 230,314
Free Scan: Update Your PC's Outdated Drivers to Optimize Performance
Old October 8th, 2008, 02:11 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 2
C# Access Database Updating

Hello, I am trying to update my database. I can update it on my first pass, but after that, the database will not update.

Code:
 Connection.Open();
                SQLString = "UPDATE NodeData SET NSB=?, Type=?, Description=?, LOSrange=?, RadioTX=?, RXsens=?, AntHeight=?, AntGain=?, Frequency=? WHERE ID=?";
                Command.Connection = Connection;
                Command.CommandText = SQLString;
                Command.CommandType = CommandType.Text;
                Command.Parameters.AddWithValue("NSB", node);
                Command.Parameters.AddWithValue("Type", type);
                Command.Parameters.AddWithValue("Description", desc);
                Command.Parameters.AddWithValue("LOSrange", los);
                Command.Parameters.AddWithValue("RadioTX", txp);
                Command.Parameters.AddWithValue("RXsens", rxs);
                Command.Parameters.AddWithValue("AntHeight", anth);
                Command.Parameters.AddWithValue("AntGain", antg);
                Command.Parameters.AddWithValue("Frequency", fre);
                Command.Parameters.AddWithValue("ID", kid);
                try
                {
                    int x = Command.ExecuteNonQuery();
                    if (x > 0)
                        MessageBox.Show("Database was updated");
                    else
                        MessageBox.Show("Database was not updated");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error = " + ex.ToString());
                }
Any help is appreciated.

matt314hew is offline   Reply With Quote
TechIMO.com Ads - Login or register for less ads.
How many errors does your computer have?

You no longer need to guess! This free stability scan and registry cleaner download will give you a complete diagnosis of your Windows registry, identifying errors and conflicts.

FREE instant scan


Guest, Register Free! to remove this ad and get your tech support questions answered in minutes!
Old October 9th, 2008, 09:52 PM     #2 (permalink)
Member
 
Join Date: Oct 2003
Posts: 247
uhhh

First off you can probably just use the following...no need to declare another variable

Code:
 if (Command.ExecuteNonQuery()>0)
       MessageBox.Show("Database was updated");
 else
       MessageBox.Show("Database was not updated");
I am a little confused with your question....

Is it throwing an error the second time? or just not updating?

Logically just reading your question your code should work fine (considering you pass in a correct connection string and pass in the correct variables, etc.).

I would check your sql on the 2nd time around and see if it will update just using the query in msaccess.

make sure you are passing in different variables for each pass.

I just tried it using my example and everything came out cool...can you post more of code so i can get a base of all your variables and such.

amtrac24 is offline   Reply With Quote
Old October 10th, 2008, 09:23 AM     #3 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 2
Thank you for the reply. I did find out what I was missing. I needed to have a Command.Dispose(); call in there. Once I did that, i was able to update everything. Not sure why it worked for you and not me.

matt314hew is offline   Reply With Quote
Old October 10th, 2008, 09:38 AM     #4 (permalink)
Member
 
Join Date: Oct 2003
Posts: 247
ahh

ahh i had this code in my own sub...so it just fell out of scope. I also was using the using keyword for the command so it would automatically dispose too.
amtrac24 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
UPdating Hardware information database wizzer Technical Support 8 November 5th, 2005 05:51 PM
Open and print Access Database without access? Winos2Mac Applications and Operating Systems 3 September 17th, 2004 09:50 PM
MS Access Database danlindley Webmastering and Programming 7 August 2nd, 2004 10:09 PM
Access Database Paluccie Webmastering and Programming 8 October 2nd, 2003 01:03 AM
Access Database Changes Marvinator Applications and Operating Systems 1 April 2nd, 2003 05:09 PM

Most Active Discussions
Is this a good laptop for gamming? (5)
Is It Just Me? (629)
Bought an AGP "HIS Radeon HD 3.. (18)
Outlook add-in won't remove. (5)
Presario Help (6)
Misery Loves Company... (1865)
Folderchat: The Holiday thread (156)
No supermajority! (13)
Putting together my wish list (14)
Recent Discussions
Is this a good laptop for gammi.. (5)
Outlook add-in won't remove. (5)
Seald copy of windows 95 for sa.. (1)
help! jumbled text and computer.. (2)
Need to retrieve files from a v.. (7)
.NET Framework 3.5 Error (0)
Looking for some help (3)
is there a way to Grep for a sp.. (5)
is this a good overal gaming la.. (1)
RAM Upgrade (8)
Magellan RoadMate 1412 GPS Perf.. (2)
FS: Dell 6000 laptop, modded 36.. (2)


All times are GMT -4. The time now is 05:19 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28