Unclosed quotation mark after the character string ''. Incorrect syntax near 's'.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
This code had been working fine, but I added "DateCreated" (DateTime.Now value), and Links, (texbox7.text value) and now I am getting this error:
<span style="font-family:Verdana; font-size:11px; line-height:normal
<h1 style="font-weight:normal; font-size:18pt; color:red Server Error in / Application.
<hr color="silver" size="1" width="100%
</h1>
<h2 style="font-weight:normal; font-size:14pt; color:maroon Unclosed quotation mark after the character string .<br/>
Incorrect syntax near s.

<span style=" Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br/>
<br/>
Exception Details: System.Data.OleDb.OleDbException: Unclosed quotation mark after the character string .<br/>
Incorrect syntax near s.<br/>
<br/>
Source Error:
<table bgcolor="#ffffcc" width="100%
<tbody>
<tr>
<td>
Code:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
</td>
</tr>
</tbody>
</table>
<br/>
Stack Trace:
<table bgcolor="#ffffcc" width="100%
<tbody>
<tr>
<td>
Code:
<pre style="font-family:Consolas,Lucida Console,monospace; font-size:11pt; padding:0.5em; line-height:14pt [OleDbException (0x80040e14): Unclosed quotation mark after the character string .
Incorrect syntax near s.]
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +745
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +107
   WebApplication1._Default.Button1_Click(Object sender, EventArgs e) +814
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9553594
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
[/code]</td>
</tr>
</tbody>
</table>


Heres my code:
<pre class="prettyprint using (OleDbConnection conn = new OleDbConnection())
{
conn.ConnectionString = @"Provider=SQLOLEDB;Server=AirSignDMCSQLExpress;Database=AirSignDB;Integrated Security=SSPI;";
string sql = string.Format("INSERT INTO dbo.Events (EventName, StartDateTime, EndDateTime, Clients, Location, Notes, DateCreated, Links ) VALUES({0},{1},{2},{3},{4},{5},{6},{7}", TextBox1.Text, startdate, enddate, TextBox4.Text, TextBox5.Text, TextBox6.Text, DateTime.Today, TextBox7.Text );
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{

try
{
conn.Open();
cmd.ExecuteNonQuery();
}

finally
{
conn.Close();
}
conn.Close();[/code]
Any ideas?


View the full article
 
Back
Top