- General Computer
- Upgrade ANT
- Windows
- Mac
- Linux
- General Softwares
- Hardwares
- Monitor
- Hard Disk Drive
- CPU
- RAM
- Mainboard
- Fax
- Router
- Modem
- Hub
- Microsoft Office
- Microsoft Word
- Microsoft Excel
- Microsoft PowerPoint
- Microsoft Outlook
- Other Microsoft Office Products
- Khmer Unicode
- General
- Programming
- Computer Security
- Virus & Spyware
- Spam Mail
- Hacking
- Network & Server
- Network
- Windows Server
- Active Directory
- Microsoft Exchange Server
- Web Server
- Domain Name System (DNS)
- Virtual Private Network (VPN)
- Web Development
- AJAX
- ASP.NET
- PHP & Apache
- JSP (Java Server Page)
- CGI
- Silverlight
- Adobe Flash
- Web Hosting
- Programming Language
- HTML
- CSS
- Javascript
- C / C++
- Visual C#
- Visual Basic
- Visual C++
- Java
- XAML
- Python
- ActionScript
- T-SQL
- XML
- Desktop Development
- General Desktop Development
- .NET Windows Applicaiton
- Java Windows Applicaiton
- Database Management
- Microsoft Access
- MySQL
- Microsoft SQL Server
- Oracle
- .NET Technologies
- Windows Workflow Foundation (WF)
- Windows Presentation Foundation (WPF)
- Windows Communication Foundation (WCF)
- Windows CardSpace
- Language Integrated Query (LINQ)
- Microsoft Expression
- Expression Blend
- Expression Studio
- Expression Design
- Expression Web
- Expression Media
- Expression Encoder
- Architecture
- Model View Controller (MVC)
- Design Pattern
- Enterprise Library
- Graphic Design
- Adobe Photoshop
- Adobe Illustrator
- Corel Draw
- Quark Express
- Cell Phone
- Nokia
- Sony Ericsson
- O2
- Samsung
- iPhone
how to save special string <'> to ms sql sever
2 replies.

kheang_chea
Joined: 19-01-2010 02:38 AM
Posts 3
19-01-2010 10:05 AM
SQLCommand = "INSERT INTO [ProdOrder]([LPO_Desc]) VALUES " + "(" + txtLPODesc.Text.Trim() +"')";
above is my sql command, I try to insert string data from txtLPODesc textbox in to ProdOrder table, field LPO_Desc.
my problem: when txtLPODesc.text = MEN's T-shirt. then i execute above command it show error msg
if txtLPODesc.text not contain <'> string it will not have problem.
can any one help me how to solve the problem?
best regards,
Kheang
Reply | Report Abuse

silverserey
Joined: 01-09-2009 08:52 AM
Posts 5
19-01-2010 11:08 AM
ចំពោះបញ្ហានេះអ្នកអាចមានជំរើសច្រើនក្នុងការប្រើប្រាស់ Sql statement ដូចជា ការប្រើប្រាស់ Stored Procedures រឺជំនួសដោយការប្រើប្រាស់ Parametter ខាងក្រោមនេះគឹជាការរបៀបនៃការប្រើប្រាស់ Parametter៖
SqlCommand cmd = new SqlCommand("INSERT INTO [ProdOrder]([LPO_Desc]) VALUES (@1)", SqlConnectionString);
cmd.Parameters.Add("@1", SqlDbType.VarChar, 20).Value = txtLPODesc.Text.Trim() ;
បន្ទាប់មកអ្នកអាចបើក Connection និង ធ្វើការ Excute នូវ SqlCommand។
សិរី,
Reply | Report Abuse

eprasart
Joined: 01-12-2009 10:47 PM
Posts 20
19-01-2010 01:45 PM
The best thing to handle this is to pass the value (from text box) through parameters as Serey did.
If you prefer your way, you just need to escape the quote by double quote like:
INSERT INTO table1 (column1) VALUES ('Someone''s name')
Reply | Report Abuse

