Hi to all ! I have problem with C# and access databasses!
I can't to insert new record in database , ( I mean I made grid view and connect him with a access database and made all things to insert data in column in datagridview and it showing that row is filed with new data but when I restart form in database there is no new record)..
I use for exmpl: same code but with OLEDB; -
-
string connectionString = "Data Source=SERV\\SQLEXP;Initial Catalog=tempdb;Integrated Security=True";
-
string command = "UPDATE telefon
-
SET prezime="+textBox2.Text+",telefon="+textBox3.Text+"
-
WHERE ime ="+textBox1.Text+"";
-
-
SqlConnection con = new SqlConnection(connectionString);
-
SqlCommand cmd = new SqlCommand(command, con);
-
-
con.Open();
-
cmd.ExecuteNonQuery();
-
con.Close();
-
this.telefonTableAdapter.Fill(this.tempdbDataSet.telefon);
-
and this work in SQL but when I use this same code EXCEPT USING SYSTEM.DATA.OLE DB;
it all works well on form it show adding a data to gridview but it not store in database, I was use : - this.telefonTableAdapter.Update();
- this.telefonTableAdapter.Insert();
-
AcceptChanges();
but it NOT SAVE DATA TO ACCESS DATABASSES
PLEASE HELP!!!
4 12971 MMcCarthy 14,534
Recognized Expert Moderator MVP
Try changing this code ... -
-
string command = "UPDATE telefon
-
SET prezime="+textBox2.Text+",telefon="+textBox3.Text+"
-
WHERE ime ="+textBox1.Text+"";
to this ... -
-
string command = "UPDATE telefon
-
SET prezime='" & textBox2.Text & "', telefon='" & textBox3.Text & "'
-
WHERE ime ='" & textBox1.Text & "'";
-
The single quotes are because Access requires single quotes for text inserts. The ampersand becuase that is what would normally be used but if you feel C# syntax requires the + sign instead then put it back.
thanx! for help I will tray it !
Tnx mmccarthy that is fine now , but ????????
I have this code and it's work on gridview it showing inserted values but it do not save changes in database !!!!
countRow++;
string str;
con.Open();
str = "insert into tele(ime,broj) values('"+textB ox1.Text+ "','"+textBox2. Text+ "')";
DataRow dRow;
DataTable dTable = db1DataSet.tele ;
dRow = dTable.NewRow() ;
dRow[1] = textBox1.Text;
if(textBox2.Tex t!="")
dRow[2] = textBox2.Text;
dTable.Rows.Add (dRow);
DataTable tab1 = db1DataSet.tele .GetChanges();
ole.Update(tab1 );
db1DataSet.tele .AcceptChanges( );
PLEASE HELP I WAS TRYING A LOT OF THINGS AND EVEN NOW I CAN' T TO SAVE DATA IN ACCESS DATABASE!!
MMcCarthy 14,534
Recognized Expert Moderator MVP
string str;
con.Open();
str = "insert into tele(ime,broj) values('"+textB ox1.Text+ "','"+textBox2. Text+ "')";
I can only help with the Access side of things. However, one this seems clear. You have put the INSERT statement into a string but you never execute it. Depending on how you connected to the database this would require something like.
Mayr
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Stuart McGraw |
last post by:
I haven't been able to figure this out and would
appreciate some help...
I have two tables, both with autonumber primary
keys, and linked in a conventional master-child
relationship. I've created forms for both those
tables, and inserted the child table form into the
master table form as a subform. It works just as
it is supposed to, in that I can create a new master
record, and then add detail records.
|
by: manning_news |
last post by:
Has anyone had a problem with Access 2003 not saving their coding?
I've been using 2003 for a couple of months now and just this week
noticed that some coding I'd done for a database was not there anymore.
I reentered it and didn't have any problems for a couple of days.
Today I entered some coding, saved it, opened another database, and
when I opened my original database again, the coding I had entered was
missing.
Access 2000 always...
|
by: Mark |
last post by:
I have a VB 6 program that I have saved an audio file to using DAO and the
appendchunk as is shown at http://support.microsoft.com/kb/103257/EN-US/. ; I
have it working fine in that app (it saves to an access database and I can
save the data back to a file using getchunk and everything works correctly).
The issue is that I am now trying to access the database in VB.NET 2003
through an OleDBDataAdapter (Jet 4.0 connection) and can't get it...
|
by: Pedro Leite |
last post by:
Good Afternoon.
the code below is properly retreiving binary data from a database and saving
it. but instead of saving at client machine is saving at the server machine.
what is wrong with my code ??
thank you
Pedro Leite From Portugal
------------------------------------
|
by: chiefsitebuilder |
last post by:
I have a question about saving an MS Access program to CD and verifyng
that the program works after being saved.
Here is my situation, I have a person who developed an application for
me using MS Access 2003 and the person will be transferring ownership
to me. The developer will be giving me a CD with Access DBase source
code on it. How do I verify that he gives me everthing I need to run
the application once the developer departs. ...
| |
by: Nathan Guill |
last post by:
I have an interface that works with an Access back-end. I would like to
store and/or load user defined query strings per each user (i.e. no user can
access another's queries). The idea I had was a "table" stored with the C#
front-end (not in the Access database), but don't know if this is even
possible. If it is, can someone let me know how? Otherwise, how do other
people handle storing and loading query strings for possible later use?
|
by: SilentThunderer |
last post by:
Hey folks,
Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form allows the employee to enter their UserID and select "Login" or "Logout" and then click a submit. When the submit button is clicked, I want the application to dum the NT Userename, UserID, status (Login or Logout) and a date/time stamp into an MS Access...
|
by: nmrpa91290 |
last post by:
I have a vb 2005 program that I am writing. It is just a form with a
datagridview, textbox, and import command button. The code looks like
this:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'TestDbDataSet.TestTable' table. You can move, or remove it, as
needed.
Me.TestTableTableAdapter.Fill(Me.TestDbDataSet.TestTable)
|
by: madhu raju |
last post by:
iam saving the data into Ms-Access database using Vb.net Application
In that application iam using Data grid view to save the data into the database
Here in the below code iam saving the name of stalls into the database
i have to save according to number given in the textbox .but first i saved only two stallnames and next time i want to save the remaining stall names then it is not possible it checks the starting two stallnames and...
|
by: Marilyth |
last post by:
I am using Windows XP and Access 2003. I have searched through my HUGE book & the questions here, and found some items that "might" help, but unsure still. I am still getting versed on Access. I know there are expressions, however the order and manner in which they need to be phrased is still a work in progress.
I am looking for help creating some code/expressions. The database is summarized below:
1. The form is open for data entry to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |