Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3215586
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:11:42+00:00 2026-05-17T15:11:42+00:00

I am trying to insert html pages to MySQL with my Asp.NET project but

  • 0

I am trying to insert html pages to MySQL with my Asp.NET project but i am getting error;

 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'de Osman patlaması', '', '<div style=\"text-align: center\">\r\n<img src=\"/i' at line 1

How can i fix that problem my server side code is;

MySqlConnection myCon = new MySqlConnection();
myCon.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
MySqlCommand cmd = new MySqlCommand();
cmd.CommandType = CommandType.Text;

string query = @"INSERT INTO `test`.`posts` (`id`, `author`, `title`, `description`, `content`, `ispublished`, `iscommentsenabled`, `pubDate`, `lastModified`, `raters`, `rating`, `slug`, `tags`, `categories`) VALUES (NULL, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}')";
query = String.Format(query, p.author, p.title, p.description, p.content, p.ispublished, p.iscommentsenabled, p.pubDate, p.lastModified, p.raters, p.rating, p.slug, p.tags, p.categories);

cmd.CommandText = query;
cmd.Connection = myCon;
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

Thanks for your help.

    MySqlConnection myCon = new MySqlConnection();
    myCon.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
    MySqlCommand cmd = new MySqlCommand(@"INSERT INTO posts (id,  author ,  title ,  description ,  content ,  ispublished ,  iscommentsenabled ,  pubDate 
    ,  lastModified ,  raters ,  rating ,  slug ,  tags ,  categories ) 
        VALUES (@id ,@author ,@title ,@description ,@content ,@ispublished ,@iscommentsenabled ,@pubDate ,@lastModified ,@raters ,@rating ,@slug ,@tags ,
        @categories ))", myCon);
    cmd.CommandType = CommandType.Text;

    cmd.Parameters.AddWithValue("@id", null);
    cmd.Parameters.AddWithValue("@author", p.author);
    cmd.Parameters.AddWithValue("@title", p.title);
    cmd.Parameters.AddWithValue("@description", p.description);
    cmd.Parameters.AddWithValue("@content", p.content);
    cmd.Parameters.AddWithValue("@ispublished", p.ispublished);
    cmd.Parameters.AddWithValue("@iscommentsenabled", p.iscommentsenabled);
    cmd.Parameters.AddWithValue("@pubDate", p.pubDate);
    cmd.Parameters.AddWithValue("@lastModified", p.lastModified);
    cmd.Parameters.AddWithValue("@raters", p.raters);
    cmd.Parameters.AddWithValue("@rating", p.rating);
    cmd.Parameters.AddWithValue("@slug", p.slug);
    cmd.Parameters.AddWithValue("@tags", p.tags);
    cmd.Parameters.AddWithValue("@categories", p.categories);
    myCon.Open();
    cmd.Prepare();
    cmd.ExecuteNonQuery();
    myCon.Close();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:11:42+00:00Added an answer on May 17, 2026 at 3:11 pm

    Use MySqlCommand.Parameters.Add to add your parameters. This auto escapes and validates your parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to insert XML into XML Column.. getting following error: . Msg 6819,
While trying to insert data to my SQl db i get the following error
I am trying to insert a string in MySQL table. But the following is
I have an html editor and I am trying to insert the html it
Hi i am trying to insert the great syntaxhighlighter into an asp .net page
I am trying to insert data about an item's price from an HTML form
I'm trying to insert some text midway through some HTML content using the following
i'm trying to insert an image in a div container using css and html,
I am trying to insert a record into a table using Linq but get
I'm trying to insert an HTML <base> tag immediately after the opening <head> tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.