473,395 Members | 1,949 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,395 software developers and data experts.

C# and Access Query

New to C# and can't quite figure out how to write my
update query correctly...(this is actually ASP.NET using
C# trying to work with Access - wasn't sure where to post)

UPDATE customer SET last_name = "" + txtLast_Name.Text
+ "";

Access needs quotes around it's strings. I can't figure
out how to do it.

I've tried this:
UPDATE customer SET last_name = "" + txtLast_Name.Text
+ """;

and this:
UPDATE customer SET last_name = "/" + txtLast_Name.Text
+ "/"";

none work...

Thanks!
Nov 16 '05 #1
3 7736
Not sure where you are putting this command but for an example, when
building a string, you can simply insert the tick mark.
Examples:
String s = "Update customer SET last_name = '" + myvariable + "'";
or even better:
String s = String.Format("Update customer SET last_name = '{0}'",
myvariable);

HTH....
"Chris" <an*******@discussions.microsoft.com> wrote in message
news:1c*****************************@phx.gbl...
New to C# and can't quite figure out how to write my
update query correctly...(this is actually ASP.NET using
C# trying to work with Access - wasn't sure where to post)

UPDATE customer SET last_name = "" + txtLast_Name.Text
+ "";

Access needs quotes around it's strings. I can't figure
out how to do it.

I've tried this:
UPDATE customer SET last_name = "" + txtLast_Name.Text
+ """;

and this:
UPDATE customer SET last_name = "/" + txtLast_Name.Text
+ "/"";

none work...

Thanks!

Nov 16 '05 #2
Chris <an*******@discussions.microsoft.com> wrote:
New to C# and can't quite figure out how to write my
update query correctly...(this is actually ASP.NET using
C# trying to work with Access - wasn't sure where to post)

UPDATE customer SET last_name = "" + txtLast_Name.Text
+ "";

Access needs quotes around it's strings. I can't figure
out how to do it.


You don't - you use parameters instead. That way you don't have to do
any quoting, and you don't risk a SQL injection attack.

See http://www.pobox.com/~skeet/csharp/faq/#db.parameters

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
Shameless plug:

I recently included in my blog text for using the Queries built in Access with an ODBC connection. I couldn't find any really useful resource for this, so I built one that works for me:

http://www.thespoke.net/MyBlog/Capta...nk/MyBlog.aspx

"unknown" wrote:
Community Message Not Available

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

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...
1
by: Joris Kempen | last post by:
Hi people, I know that the question has come around sometimes: How to open an Access Report using ASP and export it to for example RTF. I'm trying to implement the first method of David...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
4
by: bhbgroup | last post by:
I have a query on one large table. I only add one condition, i.e. a date (the SQL reads like 'where date > parameterdate'. This query is rather quick if 'parameterdate' is either explicitly...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
4
by: tt40 | last post by:
Anyone know how to prevent Access 2002 from automatically breaking all the incorrect joins in a query and then automatically saving the broken query? This is what I would call stupid design...
6
by: InnoCreate | last post by:
Hi everyone. I've recently written a classic asp website which uses an MS Access datasource. I know this is less than an ideal data source as it has limited functionality. I have a search form on...
3
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window...
6
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
13
by: magickarle | last post by:
Hi, I got a pass-through query (that takes about 15 mins to process) I would like to integrate variables to it. IE: something simple: Select EmplID from empl_Lst where empl_lst.timestamp between...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
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...
0
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...
0
tracyyun
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...

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.