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

How to ignore ' char in sql query, c#

lightwalker19
Hello how can i ignore a ' char in a sql query?
i want to put this into a table,"i can't work today."
but it gives this error "Incorrect syntax near 't'.
Unclosed quotation mark after the character string ')'."
please help :(


Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. AppSettingsReader asr = new AppSettingsReader();
  4. string conn = asr.GetValue("ConnectionString", typeof(System.String)).ToString();
  5. SqlConnection sc = new SqlConnection(conn);
  6. sc.Open();
  7. string query = "INSERT INTO Lang(lang)VALUES('" + "i can't work today." + "')";
  8.  
  9. SqlCommand command = new SqlCommand(query, sc);
  10. command.ExecuteNonQuery();
  11. sc.Close();
  12.  
  13.  
Sep 1 '12 #1
1 2412
Found the solution.... I was coding wrong :P http://www.csharp-station.com/Tutori.../Lesson06.aspx
Sep 1 '12 #2

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

Similar topics

8
by: david | last post by:
Hello, Is the code below correct ? I always get an seg fault on execution and the debugger points to c_str() ? Basically i want to convert the value std::string to char * within the iterator...
23
by: FrancisC | last post by:
#include <stdio.h> int file_copy( char *oldname, char *newname ); int main() { char source, destination; printf("\nEnter source file: ");
5
by: jab3 | last post by:
(again :)) Hello everyone. I'll ask this even at risk of being accused of not researching adequately. My question (before longer reasoning) is: How does declaring (or defining, whatever) a...
1
by: Nuno Morgadinho | last post by:
Hello all, I'm messing around with the Server Programming Interface and the particular example presented at: http://www.postgresql.org/docs/current/interactive/spi-examples.html Ideally, I...
2
by: Jon Lapham | last post by:
I have a table that stores TEXT information. I need query this table to find *exact* matches to the TEXT... no regular expressions, no LIKE queries, etc. The TEXT could be from 1 to 10000+...
10
by: dbz | last post by:
Hello everyone. I have a query. Lets say that following is given:- struct struct1{ char *word; int n; } *p; QUERIES: What does the following refer to?
2
by: chets | last post by:
Hi All, I am facing problem in executing one dynamic query in PRO *C program on linux. I want to update table mytable by data MADURAI for a column mycolumn1 where primary key is myPK.I want to...
14
by: gert | last post by:
Why does query = www ? int main(void) { char *user="www"; char *password=""; char *database="www"; char *query={"SHOW DATABASES;"}; db(user,password,database,query);
11
by: =?Utf-8?B?U3RlZmFuIFdpbGhlbG0=?= | last post by:
Hello, played a little with orcas and went into a problem by building dynamic queries. I want to build a dynamic where clause but only with parameters that are not empty =(TextBox.Text != "")....
1
by: waqasahmed996 | last post by:
Hi I am facing a strange problem. I have a duplicate entry message even though i am using IGNORE in query. My query is insert ignore into table1 select * from table2 Error is: Error Code :...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.