473,325 Members | 2,870 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,325 software developers and data experts.

Problem saving data to MS Access

Here is my code for a “Save” button on my VB Form:
Expand|Select|Wrap|Line Numbers
  1.         Dim conStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\TafitaDB.mdb;Persist Security Info=True"
  2.         Dim objCon As New OleDbConnection(conStr)
  3.         Dim sqlInsert As String = "insert into service values(@service_id,@service_type,@price)"
  4.         Dim cmd As New OleDbCommand(sqlInsert, objCon)
  5.  
  6.         Try
  7.             objCon.Open()
  8.             cmd.Parameters.AddWithValue("@service_id", OleDbType.Integer).Value = txtServiceID.Text
  9.             cmd.Parameters.AddWithValue("@service_type", OleDbType.WChar).Value = txtServType.Text
  10.             cmd.Parameters.AddWithValue("@price", OleDbType.Currency).Value = txtPrice.Text
  11.             cmd.ExecuteNonQuery()
  12.             MsgBox("Data save successful", MsgBoxStyle.OkOnly, "Tafita Electronic System")
  13.         Catch ex As Exception
  14.             MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Tafita Electronic System")
  15.         Finally
  16.             objCon.Close()
  17.             objCon.Dispose()
  18.         End Try
My problem is that when I click the “Save” button on my Form nothing is saved on my MS Access DB. Can anyone help me please? Thanks in advance.
Sep 3 '13 #1
6 1716
zmbd
5,501 Expert Mod 4TB
VB or VBA - slight difference in flavors
Sep 3 '13 #2
I'm using vb.net to create my programs.
Sep 4 '13 #3
zmbd
5,501 Expert Mod 4TB
More than likely we'll need to move this thread to either VB or .Net forum...

even before we get this moved, now that we know what language you are using, someone will come along to help so hang in there!

In the meantime, please provide a LOT more detail about which version of the .Net you are using, what version of the Access datbase you are trying to connect to, what operating system you working under.
ANY ERRORS! Complete with Title, Number, and Description as given in the dialog...

IN VBA, I'd have you do a compile, I'm sure there's the equivalent in your editor, I'd suggest that and fix any errors that popup

And just because I can... I'm going to take a poke in the dark and suggest that you verify your connection string in line 1, and I absolutly detest the way line 2 is used to create your object... I see this in VBA and often there's an issue... better (IMHO) to cast the object variable as object and the "SET" the object in a seperate line. I know that MS shows the method you've used as the "new" and "exciting" method; however, it makes troubleshooting a real pain.
Sep 4 '13 #4
thnx 4 help. I managed to find a way to save data from a form to access.mdb. I moved the db to a debug folder. I'm not sure whether its the right thing to do but it works.
Sep 6 '13 #5
zmbd
5,501 Expert Mod 4TB
Sorry about the delay....
I sent this over to be discussed as to which forum would be most helpful for your question.

As for your current solution, I think that is only a temporary means to an end.

Hopefully someone with more knowledge will be able to point you towards a more permanent solution.
Sep 7 '13 #6
Ok thanx again. I hope a permanent solution will be available.
Sep 8 '13 #7

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

Similar topics

8
by: Frnak McKenney | last post by:
Back when computer dinosaurs roamed the earth and the precursors to today's Internet were tiny flocks of TDMs living symbiotically with the silicon giants, tracking access to data processing...
2
by: RipTide | last post by:
Background: Using an unsupported/abandoned multi-user multi-database program that uses Access 97 and Jet 3.5. Program itself appears to have been built with PowerBuilder 6.5. Databases reside on...
0
by: Mark Lewin | last post by:
Hi all I'm pulling my hair out over this particular problem and I'm wondering whether you clever people can help. I'm running the demo version of Access 2003, which I understand to be a...
3
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no...
1
by: Johann Blake | last post by:
I am looking for a good solution on how to implement data access in an application so that there is a clean separation between the data access layer, the business layer and the GUI layer. I am...
11
by: Newbie! | last post by:
Hi, When i try and build my project which includes a Access Database i get a error saying: `Convert` is not a member of `String` on the following code: Public Sub SetUserNameNull()
1
by: pmclinn | last post by:
I have a formated a structure as follows: <Serializable()>public structure stcOutPut private data as string private visi as string end structure Instances of this strucuture are stored in an...
1
by: Magnus | last post by:
I'm testing walkthrough saving data to a Database (Multiple Tables). http://msdn2.microsoft.com/en-us/library/4esb49b4(VS.80).aspx In the famous Customer/Order example, I'm getting referential...
2
by: Torilyn73 | last post by:
Alrighty... one problem down... 40 more to go!! (Just kidding.. not really 40.. only 32!) My database needs to be accessible via the web. I have the server information so when its ready I can...
0
by: suho | last post by:
//here i hv to filter newsitems which i already hv in my database // and save the rest. BUT i am getting some errors // PLZ HELP private void queryChannels() { int...
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
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.