Incorrect Syntax Near 'nvarchar'.
Jan 17, 2008
Hi, I hav this error when I try to delete/edit the user information from database using the SQLDataSource. Pls Help Me!! Thank you!
Protected Sub bn_reset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bn_reset.Click
tb_name.Text = ""
tb_add.Text = ""
tb_telNo.Text = ""
tb_birth.Text = ""
tb_email.Text = ""
tb_nameCredit.Text = ""
tb_expiry.Text = ""
tb_cardNo.Text = ""
tb_cvvCode.Text = ""
tb_bank.Text = ""
tb_loginId.Text = ""
tb_pswd.Text = ""
tb_confirmPswd.Text = ""
End Sub
Protected Sub bn_submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bn_submit.Click
Session("myLoginId") = tb_loginId.Text
Session("myPassword") = tb_pswd.Text
Dim cn As New SqlClient.SqlConnection()
cn.ConnectionString = ConfigurationManager.ConnectionStrings("CustomerCS").ConnectionString
Dim sql As String
sql = "Insert into CustomerTable(Name,Gender,Address,Telephone,Birthdate,Email,[Name(Credit Card)],[Credit No],[Expiry date],[CVV2/CVC2 code],[Credit Card Bank],[Login ID],Password)"
sql = sql & "Values (@pName,@pGender,@pAdd,@pTel,@pBirth,@pEmail,@pNameCredit,@pCreditNo,@pExp,@pCode,@pBank,@pLogin,@pPswd)"
Dim cmd As New SqlCommand(sql, cn)
cmd.Parameters.AddWithValue("@pName", tb_name.Text)
cmd.Parameters.AddWithValue("@pGender", rb_gender.SelectedValue)
cmd.Parameters.AddWithValue("@pAdd", tb_add.Text)
cmd.Parameters.AddWithValue("@pTel", tb_telNo.Text)
cmd.Parameters.AddWithValue("@pBirth", tb_birth.Text)
cmd.Parameters.AddWithValue("@pEmail", tb_email.Text)
cmd.Parameters.AddWithValue("@pNameCredit", tb_nameCredit.Text)
cmd.Parameters.AddWithValue("@pCreditNo", tb_cardNo.Text)
cmd.Parameters.AddWithValue("@pExp", tb_expiry.Text)
cmd.Parameters.AddWithValue("@pCode", tb_cvvCode.Text)
cmd.Parameters.AddWithValue("@pBank", tb_bank.Text)
cmd.Parameters.AddWithValue("@pLogin", tb_loginId.Text)
cmd.Parameters.AddWithValue("@pPswd", tb_pswd.Text)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
cmd.Dispose()
cn.Dispose()
Response.Redirect("Confirmation.aspx")
End Sub
End Class
View 3 Replies
ADVERTISEMENT
May 28, 2006
Can someone help me troubleshoot the following error. It was generated during the update procedure in a Web Developer Express application:
Server Error in '/XprtDr' Application.
--------------------------------------------------------------------------------
Incorrect syntax near 'nvarchar'.
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.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.
Source Error:
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.
Stack Trace:
[SqlException (0x80131904): Incorrect syntax near 'nvarchar'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +177
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2300
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +147
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1021
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +413
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +115
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +392
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +643
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg, Boolean causesValidation) +1151
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +450
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +86
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +156
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
View 3 Replies
View Related
Jan 29, 2007
When I try to insert data in sql server 2000 database with a formview. I got this error:
Line 1: Incorrect syntax near 'nvarchar'.
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.
Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'nvarchar'.
The insert statement is right and works manuallly.
INSERT INTO REUNIOES(DATA_P1, DATA_P2, [MIG/SIR], FRENTE, LIDER, ATIVIDADE, DATA_PLANEJADO, DATA_CONCLUSAO, DATA_REPLANEJAMENTO, STATUS, EQUIPE) VALUES (@DATA_P1, @DATA_P2, @MIG, @FRENTE, @LIDER, @ATIVIDADE, @DATA_PLANEJADO, @DATA_CONCLUSAO, @DATA_REPLANEJAMENTO, @STATUS, @EQUIPE)
Please, help me with this thread.
View 8 Replies
View Related
Jun 18, 2008
I"ve had some issues in developing the sql server portion of my site. The issue is editing, deleting, inserting data from a form (at least from what I can understand, I'm a beginner). Below is the error. Any help I can get is greatly appreciated!
Josh
Server Error in '/WebSite4' Application.
Incorrect syntax near 'nvarchar'.
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. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.Source Error:
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. Stack Trace:
[SqlException (0x80131904): Incorrect syntax near 'nvarchar'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +925466
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800118
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1005
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +149
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +404
System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +447
System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +72
System.Web.UI.WebControls.FormView.HandleInsert(String commandArg, Boolean causesValidation) +388
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +602
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +132
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
View 4 Replies
View Related
Jan 6, 2008
I have this issue and I can not figure out the problem. I have 4 other forms from the same database using practly the same code, slight variations based on datavalidation requirements. IIS6 SQL Express 2005.
I have tried to defint eh colum for CODE as a bound filed and as a templated field. I get the same error.ASPX Page <%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="MaintainBSP.aspx.cs" Inherits="MaintainBSP" Title="Maintain BSP Codes" %>
<%@ MasterType VirtualPath="~/Site.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><br />
<table class="mainTable" cellspacing="0" cellpadding="3" align="center">
<tr><td class="mainTableTitle">BSP Codes</td></tr>
<tr><td>
<table align="center">
<tr>
<td><asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"BorderColor="Silver"
BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center"
CellPadding="3"DataKeyNames="CODE" DataMember="DefaultView"
DataSourceID="SqlDataSource1"
OnRowEditing="GridView1_OnRowEditing"
OnRowCancelingEdit="GridView1_EndEdit"
OnRowUpdated="GridView1_EndEdit">
<Columns>
<asp:CommandField ShowEditButton="True" EditText="Edit" CancelText="Cancel" UpdateText="Update" HeaderStyle-CssClass="rptTblTitle" >
<HeaderStyle CssClass="rptTblTitle"></HeaderStyle>
</asp:CommandField>
<asp:BoundField DataField="CODE" HeaderText="Code" ReadOnly="true" HeaderStyle-CssClass="rptTblTitle" />
<asp:TemplateField HeaderText="Bottle Size" SortExpression="Btl Sz">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" MaxLength="10" Columns="10" runat="server" Text='<%# Bind("[BOTTLE$SIZE]") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Bottle Size is a required field." Text="*" ControlToValidate="TextBox1"></asp:RequiredFieldValidator><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Bottle size must be a number followed by 'ML' or 'L'" Text="*" ControlToValidate="TextBox1"
ValidationExpression="[0-9.]+(ML|L)"></asp:RegularExpressionValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("[BOTTLE$SIZE]") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="rptTblTitle" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Labeled" SortExpression="Labeled">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" MaxLength="1" Columns="2" runat="server" Text='<%# Bind("LABELED") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Labeled is a required field" Text="*" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("LABELED") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="rptTblTitle" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Bottles Per Case" SortExpression="Btls Per Case">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" Columns="4" runat="server" Text='<%# Bind("[BOTTLES$PER$CASE]") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Bottles per case must be a whole number." Text="*" ControlToValidate="TextBox3"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("[BOTTLES$PER$CASE]") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="rptTblTitle" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Liters Per Case" SortExpression="Ltrs Per Case">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" MaxLength="8" Columns="8" runat="server" Text='<%# Bind("[LITERS$PER$CASE]") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Liters per case must be a number." ControlToValidate="TextBox4" Text="*"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("[LITERS$PER$CASE]") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="rptTblTitle" />
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="True" DeleteText="Delete" HeaderStyle-CssClass="rptTblTitle" >
<HeaderStyle CssClass="rptTblTitle"></HeaderStyle>
</asp:CommandField>
</Columns>
</asp:GridView>
<table id="tblAddBSP" runat="server" width="100%">
<tr><td colspan="2" align="center"><asp:Label ID="lblAddMessage" runat="server" Text="" style="color:Red;font-weight:bold;"/></td></tr>
<tr>
<td style="font-weight:bold;">Code</td>
<td><asp:TextBox ID="txtAddCode" runat="server" MaxLength="1" Columns="2"></asp:TextBox><asp:RequiredFieldValidator ID="rfv_txtAddCode" runat="server" ErrorMessage="Please Supply a BSP Code." Text="*"
ControlToValidate="txtAddCode" SetFocusOnError="True"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Bottle Size</td>
<td><asp:TextBox ID="txtAddSize" runat="server" MaxLength="10" Columns="10"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Bottle Size is a required field." Text="*" ControlToValidate="txtAddSize"></asp:RequiredFieldValidator><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Bottle size must be a number followed by 'ML' or 'L'" Text="*" ControlToValidate="txtAddSize"
ValidationExpression="[0-9.]+(ML|L)"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Labeled</td>
<td><asp:TextBox ID="txtAddLabeled" runat="server" MaxLength="1" Columns="2"></asp:TextBox></td>
</tr>
<tr>
<td style="font-weight:bold;">Bottles Per Case</td>
<td><asp:TextBox ID="txtAddBottlesPerCase" runat="server" MaxLength="4" Columns="4"></asp:TextBox></td>
</tr>
<tr>
<td style="font-weight:bold;">Liters Per Case</td>
<td><asp:TextBox ID="txtAddLitersPerCase" runat="server" MaxLength="8" Columns="8"></asp:TextBox></td>
</tr><tr><td colspan="2" align="right"><asp:Button ID="btnAddNew" runat="server"
Text="Add BSP" onclick="btnAddNew_Click" /></td></tr>
</table>
</td>
</tr>
</table>
</td></tr>
</table><asp:ValidationSummary ID="ValidationSummary1" runat="server"
ShowMessageBox="True" ShowSummary="False" /><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SqlConnectionString %>"
ProviderName="<%$ ConnectionStrings:SqlConnectionString.ProviderName %>"DeleteCommand="DELETE FROM BSP WHERE CODE = @CODE" InsertCommand="INSERT INTO BSP (CODE, BOTTLE$SIZE, LABELED, BOTTLES$PER$CASE, LITERS$PER$CASE) VALUES (@CODE, @BOTTLE$SIZE, @LABELED, @BOTTLES$PER$CASE, @LITERS$PER$CASE)"
SelectCommand="SELECT CODE, BOTTLE$SIZE, LABELED, BOTTLES$PER$CASE, LITERS$PER$CASE FROM BSP order by CODE"
UpdateCommand="UPDATE BSP SET BOTTLE$SIZE = @BOTTLE$SIZE, LABELED = @LABELED, BOTTLES$PER$CASE = @BOTTLES$PER$CASE, LITERS$PER$CASE = @LITERS$PER$CASE WHERE [CODE] = @CODE">
<UpdateParameters>
<asp:Parameter Name="BOTTLE$SIZE" type="String" />
<asp:Parameter Name="LABELED" type="Char" />
<asp:Parameter Name="BOTTLES$PER$CASE" type="Int32" />
<asp:Parameter Name="LITERS$PER$CASE" type="Decimal" />
<asp:Parameter Name="CODE" type="Char" />
</UpdateParameters>
<InsertParameters>
<asp:ControlParameter ControlID="txtAddSize" Name="BOTTLE$SIZE" type="String" />
<asp:ControlParameter ControlID="txtAddLabeled" Name="LABELED" type="Char" />
<asp:ControlParameter ControlID="txtAddBottlesPerCase" Name="BOTTLES$PER$CASE" type="Int32" />
<asp:ControlParameter ControlID="txtAddLitersPerCase" Name="LITERS$PER$CASE" type="Decimal" />
<asp:ControlParameter ControlID="txtAddCode" Name="CODE" type="Char" />
</InsertParameters>
</asp:SqlDataSource>
</asp:Content>
CODE BEHIND
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using reports;
using System.Data.SqlClient;
public partial class MaintainBSP : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e)
{Master.ActiveTab = Helpers.Tabs.Admin;Security.CheckPageAccess(Security.AccessTypes.Administrator);
}protected void GridView1_OnRowEditing(Object sender, GridViewEditEventArgs e)
{tblAddBSP.Visible = false;
}protected void GridView1_EndEdit(Object sender, EventArgs e)
{tblAddBSP.Visible = true;
}protected void btnAddNew_Click(object sender, EventArgs e)
{
try
{
SqlDataSource1.Insert();lblAddMessage.Text = "Add BSP '" + txtAddCode.Text + "' successful.";
txtAddCode.Text = String.Empty;txtAddSize.Text = String.Empty;
txtAddLabeled.Text = String.Empty;txtAddBottlesPerCase.Text = String.Empty;txtAddLitersPerCase.Text = String.Empty;
}catch (SqlException ex)
{if (ex.Number == 2627)
{
lblAddMessage.Text = "The code '" + txtAddCode.Text + "' is already in the database.<br />Select another code for this BSP.";txtAddCode.Text = String.Empty;
}
elselblAddMessage.Text = ex.Number + " - " + ex.ErrorCode.ToString() + " - " + ex.Message;
}
catch
{lblAddMessage.Text = "There was an issue inserting the BSP Code '" + txtAddCode.Text + "'. Please check the values and try again.";
}
}
}
View 5 Replies
View Related
May 27, 2008
This is the error it gives me for my code and then it calls out line 102. Line 102 is my buildDD(sql, ddlPernames) When I comment out this line the error goes away, but what I don't get is this is the same way I build all of my dropdown boxes and they all work but this one. Could it not like something in my sql select statement. thanksPrivate Sub DDLUIC_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDLUIC.SelectedIndexChanged
Dim taskforceID As Byte = ddlTaskForce.SelectedValueDim uic As String = DDLUIC.SelectedValue
sql = "select sidstrNAME_IND from CMS.dbo.tblSIDPERS where sidstrSSN_SM in (Select Case u.strSSN from tblAssignedPersonnel as u " _
& "where u.bitPresent = 1 and u.intUICID in (select intUICID from tblUIC where intTaskForceID = " & taskforceID & " and strUIC = '" & uic & "'))"ddlPerNames.Items.Add(New ListItem("", "0"))
buildDD(sql, ddlPerNames)
End Sub
View 2 Replies
View Related
May 20, 2008
Why does the following call to a stored procedure get me this error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'CONVERT'.
Code Snippet
EXECUTE OpenInvoiceItemSP_RAM CONVERT(DATETIME,'01-01-2008'), CONVERT(DATETIME,'04/30/2008') , 1,'81350'
The stored procedure accepts two datetime parameters, followed by an INT and a varchar(10) in that order.
I can't find anything wrong in the syntax for CONVERT or any nearby items.
Help me please. Thank you.
View 7 Replies
View Related
Dec 14, 2003
I keep receiving the following error whenever I try and call this function to update my database.
The code was working before, all I added was an extra field to update.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'
Public Sub MasterList_Update(sender As Object, e As DataListCommandEventArgs)
Dim strProjectName, txtProjectDescription, intProjectID, strProjectState as String
Dim intEstDuration, dtmCreationDate, strCreatedBy, strProjectLead, dtmEstCompletionDate as String
strProjectName = CType(e.Item.FindControl("txtProjectName"), TextBox).Text
txtProjectDescription = CType(e.Item.FindControl("txtProjDesc"), TextBox).Text
strProjectState = CType(e.Item.FindControl("txtStatus"), TextBox).Text
intEstDuration = CType(e.Item.FindControl("txtDuration"), TextBox).Text
dtmCreationDate = CType(e.Item.FindControl("txtCreation"),TextBox).Text
strCreatedBy = CType(e.Item.FindControl("txtCreatedBy"),TextBox).Text
strProjectLead = CType(e.Item.FindControl("txtLead"),TextBox).Text
dtmEstCompletionDate = CType(e.Item.FindControl("txtComDate"),TextBox).Text
intProjectID = CType(e.Item.FindControl("lblProjectID"), Label).Text
Dim strSQL As String
strSQL = "Update tblProject " _
& "Set strProjectName = @strProjectName, " _
& "txtProjectDescription = @txtProjectDescription, " _
& "strProjectState = @strProjectState, " _
& "intEstDuration = @intEstDuration, " _
& "dtmCreationDate = @dtmCreationDate, " _
& "strCreatedBy = @strCreatedBy, " _
& "strProjectLead = @strProjectLead, " _
& "dtmEstCompletionDate = @dtmEstCompletionDate, " _
& "WHERE intProjectID = @intProjectID"
Dim myConnection As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("connectionstring"))
Dim cmdSQL As New SqlCommand(strSQL, myConnection)
cmdSQL.Parameters.Add(new SqlParameter("@strProjectName", SqlDbType.NVarChar, 40))
cmdSQL.Parameters("@strProjectName").Value = strProjectName
cmdSQL.Parameters.Add(new SqlParameter("@txtProjectDescription", SqlDbType.NVarChar, 30))
cmdSQL.Parameters("@txtProjectDescription").Value = txtProjectDescription
cmdSQL.Parameters.Add(new SqlParameter("@strProjectState", SqlDbType.NVarChar, 30))
cmdSQL.Parameters("@strProjectState").Value = strProjectState
cmdSQL.Parameters.Add(new SqlParameter("@intEstDuration", SqlDbType.NVarChar, 60))
cmdSQL.Parameters("@intEstDuration").Value = intEstDuration
cmdSQL.Parameters.Add(new SqlParameter("@dtmCreationDate", SqlDbType.NVarChar, 15))
cmdSQL.Parameters("@dtmCreationDate").Value = dtmCreationDate
cmdSQL.Parameters.Add(new SqlParameter("@strCreatedBy", SqlDbType.NVarChar, 10))
cmdSQL.Parameters("@strCreatedBy").Value = strCreatedBy
cmdSQL.Parameters.Add(new SqlParameter("@strProjectLead", SqlDbType.NVarChar, 15))
cmdSQL.Parameters("@strProjectLead").Value = strProjectLead
cmdSQL.Parameters.Add(new SqlParameter("@dtmEstCompletionDate", SqlDbType.NVarChar, 24))
cmdSQL.Parameters("@dtmEstCompletionDate").Value = dtmEstCompletionDate
cmdSQL.Parameters.Add(new SqlParameter("@intProjectID", SqlDbType.NChar, 5))
cmdSQL.Parameters("@intProjectID").Value = intProjectID
myConnection.Open()
cmdSQL.ExecuteNonQuery
myConnection.Close()
MasterList.EditItemIndex = -1
BindMasterList()
End Sub
Thankyou in advance.
View 3 Replies
View Related
May 22, 2008
What I am trying to create a query to check, If recDT is not value or null, then will use value from SELECT top 1 recDtim FROM Serv. Otherwise, will use the value from recDT. I have tried the below query but it doesn't work. The error says, Incorrect syntax near the keyword 'SELECT'.Incorrect syntax near the keyword 'else'.1 SELECT
2 case when recDT='' then SELECT top 1 recDtim FROM Serv else recDT end
3 FROM abc
4
Anyone can help? Thanks a lot.
View 5 Replies
View Related
Jul 26, 2006
I am not sure how to fix this??
Imports System.Data
Imports System.Web.UI.WebControls.FormView
Imports System.Data.SqlClient
Partial Class Assignment
Inherits System.Web.UI.Page
Protected Sub UpdateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpdateButton.Click
Dim empID As Integer
Dim nbrID As Integer
Dim equid As Integer
Dim UpdateQuery
Dim empequipid As SqlCommand
Dim mySQLConnection As String = System.Configuration.ConfigurationManager.ConnectionStrings("DBConnectionString").ToString
Dim myConnection As New SqlConnection(mySQLConnection)
myConnection.Open()
empID = (Session("UserEmployeeID"))
equid = (Session("UserEquipID"))
If CType(empID, Integer) = Nothing Then
empID = (DropDownList1.SelectedValue)
'Response.Write("Insert: " & empID)
'Response.End()
Me.SqlDataSource1.InsertCommand = "INSERT INTO [EMPLOYEES_EQUIP] ([EquipID], [EmployeeID]) VALUES " & equid & " " & empID & ""
Me.SqlDataSource1.InsertCommand = SqlDataSourceCommandType.Text
Me.SqlDataSource1.Insert()
Else
empequipid = New SqlCommand("Select EmpEquipID From EMPLOYEES_EQUIP Where EmployeeID = " & empID & " AND EquipID = " & equid & " ", myConnection)
empequipid.CommandType = CommandType.Text
nbrID = empequipid.ExecuteScalar
'Response.Write("Select EmpEquipID: " & nbrID)
'Response.End()
empID = (DropDownList1.SelectedValue)
'Response.Write("<br>Update EmployeeID: " & empID)
'Response.End()
Me.SqlDataSource1.UpdateCommand = "UPDATE EMPLOYEES_EQUIP SET EmployeeID = " & empID & " WHERE EmpEquipID = " & nbrID & " "
Me.SqlDataSource1.UpdateCommand = SqlDataSourceCommandType.Text
Me.SqlDataSource1.Update() <---Right here is displaying "Incorrect syntax near '0'."
'Added to output the Update Query
UpdateQuery = "UPDATE EMPLOYEES_EQUIP SET EmployeeID = " & empID & " WHERE EmpEquipID = " & nbrID & " "
'Response.Write(UpdateQuery)
'Response.End()
End If
'Updating the session to new EmployeeID
Session("UserEployeeID") = (DropDownList1.SelectedValue)
'Response.Write("<br>UserEmployeeID Session: " & Session("UserEmployeeID"))
'Response.End()
'-- Turn On Employee Information Table
EmpInfo.Visible = True
'-- Hides the Employee Name's Drop Down List table.
maintable.Visible = False
End Sub
End Class
View 2 Replies
View Related
Aug 11, 2006
Why am I getting this error.
[SqlException (0x80131904): Incorrect syntax near '.123'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857418 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735030 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 WebApplication10.Edit.dgrdEdit_UpdateCommand(Object source, DataGridCommandEventArgs e) in C:Inventoryedit.aspx.vb:186 System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs e) +105 System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +471 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +117 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
View 1 Replies
View Related
Sep 8, 2006
Hi,I am trying to test a login form and I get this error message and can't find out why. Istarted out with the Login control, but since I have to try it on the ISP's server, I can't use the SQL Server Managment Studio's integrated authentication. So, I converted the login control to a template and assigned a handler for the login button:protected void LoginButton_Click(object sender, EventArgs e){String usrname = lpLogin.UserName.ToString(); //lpLogin is the <ASP:Login ...>String conString = "Data Source=mylocalserver\SQLEXPRESS;Initial Catalog=LPRU;Integrated Security=True";String selQuery = "SELECT [Password], [FirstName], [LastName] FROM [lpUserInfo] WHERE ([UserID] ='" + usrname + "';";SqlConnection con = new SqlConnection(conString);SqlCommand cmd = new SqlCommand(selQuery, con);con.Open();SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // <--- it says "syntax error near ';' " on this line, I tried it without CommandBehaviorwhile (rdr.Read()){Label1.Text= rdr.GetString(0) + rdr.GetString(1); // for testing purposes, trying to print out first name and last name}rdr.Close();con.Close();}Is there a way of using SQLServer 2000, used by my ISP, and take advantage of .net 2.0's login control, roles, membership, ...? By just using a connection string?
View 6 Replies
View Related
Feb 19, 2007
OS: Windows2kPlatform: ASP.Net 2.0.50727DB Server: SQL Server 2000 I'm getting an error that I don't understand, could someone help me please? In the interest of brevity I threw most of the query out (it's a somewhat long join). --- query += "AND TOURNAMENT_ROUNDS.END_TIME BETWEEN ? AND ?"; System.Data.SqlClient.SqlCommand cmd = new SqlCommand(query, connection); cmd.Parameters.Add("@from",System.Data.SqlDbType.DateTime).Value = from; cmd.Parameters.Add("@to", System.Data.SqlDbType.DateTime).Value = to; SqlDataAdapter da = new SqlDataAdapter(query, connection); da.SelectCommand = cmd; DataSet ds = new DataSet(); int i = 0; try { connection.Open(); da.Fill(ds); --- The da.Fill(ds) is what's throwing. I was under the impression that ADO.Net would handle the syntax so that this shouldn't be a problem. Any idea about what direction I should be looking? If you need me to post more I'll be happy to do that. I've verified that the above is where the exception is throwing by taking out the particular AND clause, and the query worked as expected. Thanks for the help,Michael
View 2 Replies
View Related
Mar 17, 2007
Hi Guys,I have moved my asp.net app from access db over to MS SQL 2005 DB.And I have got a slight problem when I go to view any productfor example if I type in the url of http://domain.com/catalog/Details.aspx?AdNum=1I get this errorServer Error in '/catalog' Application.--------------------------------------------------------------------------------Incorrect syntax near '?'. 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. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '?'.I have attached the details.aspx.I await for some suggestions.ThanksMatthew
------------------1 <%@ Page MasterPageFile="Classy.master" Explicit="True" Language="VB" Debug="True" %>
2
3 <asp:Content runat="server" ID="HeaderContent" ContentPlaceHolderID="PageHeader">
4 Ad Detail - <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
5 </asp:Content>
6
7 <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="Body" >
8
9 <script runat="server">
10 Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
11 If Not IsPostBack Then
12 If Request.QueryString("AdNum") = "" Then
13 Response.Redirect("default.aspx")
14 End If
15 EditLink.NavigateUrl = "confirm.aspx?AdNum=" & Request.QueryString("AdNum")
16 End If
17 End Sub
18
19 Protected Sub DetailsView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewPageEventArgs)
20
21 End Sub
22 </script>
23
24
25 <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
26 CellPadding="4" DataKeyNames="AdNum" DataSourceID="SqlDataSource1" ForeColor="#333333"
27 GridLines="None" Height="65px" Width="100%" Font-Names="Arial" Font-Size="8pt" OnPageIndexChanging="DetailsView1_PageIndexChanging">
28 <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
29 <FieldHeaderStyle BackColor="#FFFF99" Font-Bold="True" />
30 <Fields>
31 <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
32 <asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" />
33 <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
34 <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
35 <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
36 <asp:TemplateField HeaderText="Email">
37 <ItemTemplate>
38 <asp:HyperLink ID="HyperLink1" runat="server" Text=Email NavigateUrl='<%# Eval("Email", "mailto:{0}") %>' />
39 </ItemTemplate>
40 </asp:TemplateField>
41 <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
42 </Fields>
43 </asp:DetailsView>
44 <p><i>To respond to this ad, just click the email address
45 above to send the poster
46 a message.</i></p>
47 If you created this ad, you can
48 <asp:hyperlink id="EditLink" runat="server" >edit or delete it.</asp:hyperlink> <br>
49 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
50 ConnectionString="<%$ ConnectionStrings:classydbConnectionString %>"
51 ProviderName="<%$ ConnectionStrings:classydbConnectionString.ProviderName %>"
52 SelectCommand="SELECT * FROM [Ads] WHERE ([AdNum] = ?)">
53 <SelectParameters>
54 <asp:QueryStringParameter Name="AdNum" QueryStringField="AdNum" Type="Int32" />
55 </SelectParameters>
56 </asp:SqlDataSource>
57
58 </asp:content>
View 4 Replies
View Related
Jun 18, 2007
Can anyone see why I would get the 'Incorrect Syntax near AS' error in this?
USE [SQL2]GO/****** Object: StoredProcedure [dbo].[PlanGroupGrid] Script Date: 06/18/2007 06:07:34 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[PlanGroupGrid]@dp_id intASSELECT tblExpenses.gp_ID, tblExpenses.Amount INTO #tempApExpFROM tblExpensesSELECT tblGroups.dp_id, tblGroups.Group_ID, tblGroups.Group_Type, tblGroups.Group_Purpose, tblGroups.Group_StartDate, tblGroups.Group_EndDate, COALESCE (tblGroups.Group_Goal, 0) AS Goal, SUM(COALESCE(#tempApExp.Amount,0)) AS [Total Expenses], SUM(COALESCE (tblReceipts.AmountPaid, 0)) AS [Total Paid], SUM(COALESCE (tblReceipts.AmountPaid, 0)) - COALESCE (tblGroups.Group_Goal, 0) - SUM(COALESCE(#tempApExp.Amount,0)) AS [Total Expenses], AS VarianceFROM tblGroups LEFT OUTER JOIN tblTracking ON tblGroups.Group_ID = tblTracking.Group_ID LEFT OUTER JOIN tblReceipts ON tblTracking.gp_ID = tblReceipts.gp_ID LEFT OUTER JOIN #tempApExp ON tblTracking.gp_ID = #tempApExp.gp_IDWHERE (tblGroups.dp_id = @dp_id)GROUP BY tblGroups.dp_id, tblGroups.Group_ID, tblGroups.Group_Type, tblGroups.Group_Purpose, tblGroups.Group_StartDate, tblGroups.Group_EndDate, tblGroups.Group_GoalIf Exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tempApExp]') and OBJECTPROPERTY(id,N'IsUserTable') = 1)Drop table #tempApExp
View 2 Replies
View Related
Jul 28, 2007
I'm getting a pop up error "Incorrect syntax near the keyword 'ORDER'.
Can someone please tell me what is wrong with my code? It worked before I added the underlined part.
If FoundChecked = True Then
Dim SQLString As String
SQLString = "SELECT ID, Bedrooms, Bathrooms, Location, Rent FROM ListingsTable WHERE "
For Each Item In LocationList.Items
If Item.Selected Then
SQLString &= " Location = '" & Item.Value & "' OR " & "" & " ORDER BY Location" ----------------------This is the problem
End If
View 8 Replies
View Related
Aug 28, 2007
Hi
I'm trying to lookup a sigle value from an MS SQL Express database. However, I get an error - Incorrect Syntax near '' - when executing the code. The line in bold below is what is highlighted on the error I get back. Please Help!!
The code is below
Thanks
Dim oSQLConn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection()oSQLConn.ConnectionString = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|SDCentral.mdf;Integrated Security=True;User Instance=True"oSQLConn.Open() Dim ValExtract As Data.SqlClient.SqlCommand = New Data.SqlClient.SqlCommand("SELECT * FROM ProjectsQRY", oSQLConn) Dim Get1 As Int32 = CInt(ValExtract.ExecuteScalar()) Me.Active1.Text = Get1
oSQLConn.Close()
View 4 Replies
View Related
Aug 28, 2007
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. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near ')'.Source Error:
Line 42: objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, objConn)Line 43: ' Fill the dataset.Line 44: objAdapter.Fill(objDataset)Line 45: ' Create a new view.Line 46: Dim oView As New DataView(objDataset.Tables(0))
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim AllorOne As String
Dim company As String
AllorOne = Request.QueryString("AllorOne")
company = Request.QueryString("company")
' Create a connection and open it.
Dim objConn As New System.Data.SqlClient.SqlConnection("User ID=******;Password=******;Initial Catalog=customer_config;Data Source=rqa4-sql01;")
objConn.Open()
Dim strSQL As String
Dim objDataset As New DataSet()
Dim objAdapter As New System.Data.SqlClient.SqlDataAdapter()
' Get all the sql
If AllorOne = "All" Then
strSQL = "SELECT [Company_Name] as 'Company Name', [Entity_Code] as 'Entity Code', [YTD_Transactions] as 'YTD_Transactions', [Num_Reports_DB] as 'Num_Reports_DB', [Reports_Advanced_Workflow] as 'Reports_Advanced_Workflow', [Has_Customization] as 'Has_Customization',[TA_Trans_All] as 'TA Trans All', [TA_Trans_US] as 'TA Trans US', [Using_VAT] as 'Using VAT', [Total_Users] as 'Total Users',[Non_English_Langages] as 'Non English Langages',[Non_English_Users] as 'Non English Users', [Using_Offline] as 'Using Offline', [Using_Audit_Services] as 'Using Audit Services' from(v_customer_master_list) order by company_name"
Else
strSQL = "SELECT [Company_Name] as 'Company Name', [Entity_Code] as 'Entity Code', [YTD_Transactions] as 'YTD_Transactions', [Num_Reports_DB] as 'Num_Reports_DB', [Reports_Advanced_Workflow] as 'Reports_Advanced_Workflow', [Has_Customization] as 'Has_Customization',[TA_Trans_All] as 'TA Trans All', [TA_Trans_US] as 'TA Trans US', [Using_VAT] as 'Using VAT', [Total_Users] as 'Total Users',[Non_English_Langages] as 'Non English Langages',[Non_English_Users] as 'Non English Users', [Using_Offline] as 'Using Offline', [Using_Audit_Services] as 'Using Audit Services' from(v_customer_master_list) where lower(company_name) like '%" & company & "%' order by company_name"
End If
objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, objConn)
' Fill the dataset.
objAdapter.Fill(objDataset)
' Create a new view.
Dim oView As New DataView(objDataset.Tables(0))
' Set up the data grid and bind the data.
SimpleDataGrid.DataSource = oView
SimpleDataGrid.DataBind()
End Sub
Can anyone tell me what causes this type of error, what they think is wrong, or what IS wrong if someone wants to take the time to go through the code. Anything helps. Eh, I feel like one of those guys on a street corner with a sign when I say that.
View 3 Replies
View Related
Nov 20, 2007
Hi there
I'm getting an Incorrect syntax near '='. error when I click update in my gridview.
Any ideas?
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Taskdb %>" SelectCommand="SELECT [taskid], [taskname], [taskdescription], [taskstatus] FROM [tblTask]" UpdateCommand="UPDATE [tbltask) set [taskname] = @taskname, [taskdescription] = @taskdescription, [taskstatus] = @taskstatus where [taskid] = @taskid"> <UpdateParameters> <asp:Parameter Type="String" Name="taskname" /> <asp:Parameter Type="String" Name="taskdescription" /> <asp:Parameter Type="Int16" Name="taskstatus" /> <asp:Parameter Type="Int16" Name="taskid" /> </UpdateParameters> </asp:SqlDataSource> Thanks in advance.
View 2 Replies
View Related
Jan 16, 2008
Could someone please tell me what is wrong with the following? Thanks!
Dim objcmd As New SqlCommand
Dim link As String
Dim pocount As Integer
objConn.Open()objcmd = New SqlCommand("SELECT COUNT(PONumber) FROM (SELECT PONumber FROM BOL_Dtl GROUP BY PONumber, BOLNumber HAVING BOLNumber = @BOLNumber)", objConn)
objcmd.Parameters.Add("@BOLNumber", SqlDbType.Int, 4)objcmd.Parameters("@BOLNumber").Value = Int32.Parse(Request.QueryString("BOLNumber"))
pocount = objcmd.ExecuteScalar()
View 2 Replies
View Related
Feb 28, 2008
Hi,
I have a table 'MemberPayment', into which I would like to pass a derived value, and a value from another table (table 'Vehicle', value 'Registration'). However, I keep getting errors with my syntax... would anybody be able to kindly tell me where I am going wrong? My code is;Declare @Total int
Declare @Registration str
SELECT (@Registration=(Vehicle.Registration), @Total=((MileageHistory.MileageUrban * Vehicle.EmissionsPerGramUrban) * 0.05) + ((MileageHistory.MileageCountry * Vehicle.EmissionsPerGramUrban) * 0.05) )
FROM [NeuCar].[dbo].[MileageHistory] JOIN [NeuCar].[dbo].[Vehicle]
ON MileageHistory.Registration = Vehicle.Registration
JOIN [NeuCar].[dbo].[Member] ON Vehicle.UserName = Member.UserName
WHERE Member.UserName = 'wenger1' AND (MileageHistory.[Date] >= CURRENT_TIMESTAMP - 30)
INSERT INTO MemberPayment (Registration, TotalCharge) VALUES ( @Registration, @Total )
Many thanks for your time,
Best regards,
Chima
View 2 Replies
View Related
Mar 14, 2008
Hi All,
When binding my dropdownlist I get this error: Incorrect syntax near '?'.
My code behind:
'Set country drop list value c = Request.QueryString("c") ddlCountry.SelectedValue = c
'Begin populating if country has been selected ddlLeaveType.DataBind()
My HTML:
<asp:DropDownList ID="ddlLeaveType" runat="server" CssClass="AdminLeaveDDL" DataSourceID="SDSLeaveTypes" DataTextField="Description" DataValueField="PTO_Leave_Type_ID"></asp:DropDownList>
<asp:SqlDataSource ID="SDSLeaveTypes" runat="server" ConnectionString="<%$ ConnectionStrings:PTOTrackConnectionString %>" ProviderName="<%$ ConnectionStrings:PTOTrackConnectionString.ProviderName %>" SelectCommand="SELECT PTO_Leave_Type_ID, Description FROM PTO_Leave_Type WHERE PTO_Leave_Type_ID NOT IN (SELECT PTO_Leave_Type_ID FROM PTO_Country_Leave_Type WHERE Country_ID = ?) ORDER BY Description"> <SelectParameters> <asp:QueryStringParameter Name="CountryID" QueryStringField="c" Type="Int32" /> </SelectParameters> </asp:SqlDataSource>
If I rund the query in sql management studio and replace the ? with a valid id, it runs fine.
Thanks,
Mark
View 5 Replies
View Related
Apr 17, 2008
Could someone please explain why the above error occurs ?
Dim connString As String = ConfigurationManager.AppSettings("Fleetcube.ConnectionString")
Dim myConnection As New System.Data.SqlClient.SqlConnection(connString)Dim Str As String = "UPDATE [sec_Administrator] SET [EmailAddress] = ?, [Password] = ?, [SecurityQuestion] = ?, [SecurityAnswer] = ? WHERE [id] = " & Session.Item("Admin_id")
Dim cmd As New System.Data.SqlClient.SqlCommand(Str, myConnection)Dim ds As New DataSetDim da As New SqlClient.SqlDataAdapter(cmd)
cmd.Parameters.Add("EmailAddress", SqlDbType.VarChar).Value = txtadmin_email.Text
cmd.Parameters.Add("Password", SqlDbType.VarChar).Value = txtadmin_pass.Text
cmd.Parameters.Add("SecurityQuestion", SqlDbType.VarChar).Value = txtadmin_SecQues.Text
cmd.Parameters.Add("SecurityAnswer", SqlDbType.VarChar).Value = txtadmin_SecAns.Text
cmd.Connection.Open()
cmd.ExecuteNonQuery()
View 14 Replies
View Related
May 15, 2008
I am getting the error Incorrect syntax near ',' while executing a query.
Here is tha code snippet.String querystring="update dbo.cstd_incident_survey set Question1="+q1+",Question2="+q2+",Question3="+q3+",Question4="+q4+ ",survey_date= '" + surveydate.ToString() + "'where incident_id='" + dr3[0]+"'";SqlCommand query4 = new SqlCommand(querystring , newconnection);
query4.ExecuteNonQuery();
Please help.
Thanks in advance,
Sangita
View 3 Replies
View Related
Jul 6, 2004
some one can help me about this error..i always get the error like this..but stilll dun know exactly what the error..pls help me..
here the message
Incorrect syntax near the keyword 'user'.
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.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'user'.
Source Error:
Line 51: Dim objdr As SqlDataReader
Line 52: conn.Open()
Line 53: objdr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Line 54: List1.DataSource = objdr
Line 55: List1.DataValueField = "user_id"
Source File: c:inetpubwwwroot
egisterupdate.aspx.vb Line: 53
Stack Trace:
[SqlException: Incorrect syntax near the keyword 'user'.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
register.update.binddata() in c:inetpubwwwroot
egisterupdate.aspx.vb:53
register.update.Page_Load(Object sender, EventArgs e) in c:inetpubwwwroot
egisterupdate.aspx.vb:42
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
View 1 Replies
View Related
Jan 16, 2006
I try to use stored procedure to do a search for Email column. But I always get a error "Incorrect syntax near '.'", when I input keyword like "ash11.tw." And if I put keyword without dot, it works fine. It seems like the dot caused the problem. But I dont know how to fix it. Can someone help me out? Thanks.
My where expression is following.
@spWhereSearch = 'where cont.Email like "%' + @Email + '%"'
View 7 Replies
View Related
May 1, 2006
Hello all,
here is my code
objConn = new
SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
objCmd = new SqlCommand("SELECT * FROM catalogue WHERE Title =" +
Request.QueryString["detail"], objConn);
objConn.Open();
objRdr = objCmd.ExecuteReader();
DataList1.DataSource = objRdr;
DataList1.DataBind();
objRdr.Close();
objConn.Close();
I am trying to select records from the database where they match the query string.
However when I run it, i get an error at objRdr =
objCmd.ExecuteReader();, incorrect Syntax Near, and the name of the
query string
Anyone have an idea?
Thanks
View 3 Replies
View Related
May 23, 2006
I keep getting this error...?
Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'c'.
Source Error:
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.
Stack Trace:
[SqlException (0x80131904): Line 1: Incorrect syntax near 'c'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +177
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2305
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
System.Data.SqlClient.SqlDataReader.get_MetaData() +62
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +294
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1021
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +20
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +107
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +10
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +140
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1659
System.Web.UI.WebControls.BaseDataList.GetData() +53
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +267
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +56
System.Web.UI.WebControls.BaseDataList.DataBind() +62
System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +55
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +62
System.Web.UI.Control.EnsureChildControls() +97
System.Web.UI.Control.PreRenderRecursiveInternal() +50
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5729
I think it talking about my SQL Query...?? If you could help me it would greatly appreciated! Thanks
strSQLQuery = "Select c.EmployeeID, c.[FirstName] as UserFirstName, c.[LastName] as UserLastName, eqtype.[Description] as UserEquipType, eq.[SerialNo] as UserSerialNum from EMPLOYEES c LEFT OUTER JOIN EQUIPMENT as eq on eq.EmployeeID = c.EmployeeID LEFT OUTER JOIN EQUIP_TYPE as eqtype on eqtype.EquipTypeID = eq.EquipTypeID"
View 5 Replies
View Related
Oct 8, 2002
I am getting the above error on the following code:
substrSql = "SELECT SUBCAT_NAME FROM DL_SUBCATEGORIES where SUBCAT_ID =" & intDLCATEGORY & ""
dim rssubCat
set rssubCat = server.CreateObject("adodb.recordset")
rssubCat.Open substrSql, my_Conn
can anyone tell me why the syntax is incorrect??
View 2 Replies
View Related
Jan 29, 2003
I don't find this syntax error in my T-SQL script - any idea?
declare @sql varchar(1000)
select @sql = 'INSERT DBCleanerTemp (TableName, trxYearMonthStart, nmbrtrx)'
select @sql = @sql + ' Select ''' + @ProcessTable + ''''
select @sql = @sql + ', ''+ CONVERT(varchar(6), ' + @SelectedColumn + ', 112) + ''01'''
select @sql = @sql + ', count(*)'
select @sql = @sql + ' from ' + @ProcessTable
select @sql = @sql + ' group by '' + CONVERT(varchar(6), ' + @SelectedColumn + ', 112) + ''01'''
print @sql
exec (@sql)
Output:
INSERT DBCleanerTemp (TableName, trxYearMonthStart, nmbrtrx) Select 'opms..Transactions', '+ CONVERT(varchar(6), TransactionDateStamp, 112) + '01', count(*) from opms..Transactions group by ' + CONVERT(varchar(6), TransactionDateStamp, 112) + '01'
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '01'.
View 1 Replies
View Related
Aug 24, 2004
hi
I get this error when i am trying to run the query on profiler :
'SELECT People.People, People.Name,
Sum(IIf(IsNull([ProjectStatusReport]![Week]),0,IIf([ProjectStatusReport]![Week]=#8/20/2004#,1,0))) AS Created,
Sum(IIf(IsNull([ProjectStatusReport]![Week]),0,IIf([ProjectStatusReport]![Week]=#8/20/2004#,IIf(IsNull([ProjectStatusReport]![Accomplishments])
Or IsNull([ProjectStatusReport]![Plans]),0,1),0))) AS Complete, People.email FROM (((Register INNER JOIN SR_Status
ON Register.SR_Status = SR_Status.SR_Status) LEFT JOIN ProjectStatusReport
ON Register.Register = ProjectStatusReport.Project) INNER JOIN StakeHolders
ON Register.Register = StakeHolders.Register) INNER JOIN People
ON StakeHolders.People = People.People WHERE (((SR_Status.Status)='Active') AND ((StakeHolders.Status)=Yes))
GROUP BY People.People, People.Name, People.email
HAVING (((Sum(IIf(IsNull([ProjectStatusReport]![Week]),0,IIf([ProjectStatusReport]![Week]=#8/20/2004#,1,0))))>0)
AND ((Sum(IIf(IsNull([ProjectStatusReport]![Week]),0,IIf([ProjectStatusReport]![Week]=#8/20/2004#,IIf(IsNull([ProjectStatusReport]![Accomplishments])
Or IsNull([ProjectStatusReport]![Plans]),0,1),0))))>0)) ORDER BY People.People'
Can anyone suggest the possible reason?
Regards
View 5 Replies
View Related
Dec 3, 2004
Can anyone tell me how to correct this error message: Line 9: Incorrect syntax near '='.
Code:
SELECT customerId AS "Customer ID", lastName AS "Last Name", phone AS "Phone", DATENAME(MONTH, saleDate) + ' ' + DATENAME(DAY, saleDate) + ', ' + DATENAME(YEAR, saleDate) AS "Sale Date" FROM Customer, Sale WHERE saleDate BETWEEN (DATENAME(MONTH, saleDate) = 'June' DATENAME(DAY, saleDate) = '1') AND(DATENAME(MONTH, saleDate) = 'June' DATENAME(DAY, saleDate) = '7')
Perhaps I defined my variables wrong?
View 2 Replies
View Related
Jun 16, 2008
I have text 060108 that I want to read 06/01/08. Here is what works.
left (oaentdate,2) + '/' + substring (oaentdate,3,2) + '/' + substring (oaendate,5,2)
However, I can't place it in the Query Select statement.
What am I doing wrong?
Lisa Jefferson
View 6 Replies
View Related