|
#1
05-06-10, 03:06 PM
|
|
|
|
Hello,
I am writing a small (ie needs to be small and portable) application, so decided to use an Access database. Having spent several frustrating hours trying to do data access, I have failed completely. I would be very grateful if anyone could help me accomplish this supposedly trivial task. I first tried doing it manually, and generating an SQL command, but that gave a syntax error when I (who has a lot of years of professional database work, and does know how to write SQL!) couldn't see one. So, I tried using parameters, like this... string sql = "update Profiles set FirstName=?, Surname=? where WebSiteID=?"; using (OleDbConnection conn = new OleDbConnection(connStr)) { using (OleDbCommand cmd = new OleDbCommand(sql, conn)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text); cmd.Parameters.AddWithValue("Surname", txtSurname.Text); cmd.Parameters.AddWithValue("ProfileID", m_ProfileId); try { conn.Open(); cmd.ExecuteNonQuery(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } However, this just didn't do anything. No error was thrown, but the database wasn't updated. I then discovered the VS2005 data access features, such as the ones shown in the walkthroughs here... http://msdn.microsoft.com/en-us/libr...=VS.71%29.aspx ....but they didn't work. I created and configured a dataset from the Access database, and then dragged the table onto the form. So far so good, I had controls for the fields, and navigation controls to move from one record to the next. Trouble was, all it did was display the data. Any changes made were not saved to the database, and any new records added weren't inserted. I tried this on two different machines, with two different databases, but the results (or lack thereof) were the same. No errors, but no database updates. Anyone any idea how I sort this out? I have been using SQL Server heavily for years and never had this sort of problem. Last time I did Access stuff was with VB6, and it all worked fine then. Am I missing something here? TIA |
|
#2
05-06-10, 05:03 PM
|
|
|
|
On 5/6/2010 11:06 AM, Alan Silver wrote:
[..] > but the results (or lack thereof) were the same. No errors, but no > database updates. > > Anyone any idea how I sort this out? I have been using SQL Server > heavily for years and never had this sort of problem. Last time I did > Access stuff was with VB6, and it all worked fine then. Am I missing > something here? > > TIA > I've always done this following the style shown here: http://msdn.microsoft.com/en-us/library/bbw6zyha.aspx |
|
Similar Threads | |
tried other stuff, didn't help I changed my DNS on my server (had it set wrong) and i had success adding and mapping a workstation. After sitting about 30 minutes, my workstation can login to the domain... |
|
Access problem restrictanonymous=0 didn't work Hi, I can view all PC's on the network in network neighbourhood and can access the files on all but PC named "study". This PC is visible but when I try to connect I get the... |
|
Data migration - 1.2 hot fix didn't work? Hi, I saved the Data Migration Framework upgrade from 1.0 to 1.2 in a separate folder than the other DMF files. I ran the CRM1.2-KB831202-Migration-ENU.exe file, but then... |
|
Reinstalled - most saved data didn't work Prior to clean reinstalling I not only saved docs, pics etc onto DVD but also Program Files folder. The reinstall got rid of some clutter but my PC is still not running as... |
|
commercial stuff I didn't ask for How do I get rid of all those fuckin' commercial adds in MSN Messenger 6.0? N |
All times are GMT. The time now is 08:13 AM. | Privacy Policy
|