Error-Line 1: Incorrect Syntax Near '='
Aug 21, 2004
hi,
i got this error when i run app.
---------------
Line 1: 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: Line 1: Incorrect syntax near '='.
Source Error:
Line 40: Dim adpt As New SqlDataAdapter("SELECT * FROM SMS_student_class_master WHERE" & _
Line 41: "stud_id=" & sid, con)
Line 42: adpt.Fill(ds, "SMS_student_class_master")
Line 43: txt.Text = ds.Tables.Item("roll_no").ToString
Line 44: con.Close()
Source File: c:inetpubwwwrootaspnetsmsassignment_d.aspx.vb Line: 42
--------
what should i do?
anyone have any idea?
plz give solution.
it's urgent.
thanks in advance
View 2 Replies
ADVERTISEMENT
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
Nov 8, 2006
G'day everyoneThat's a space between the ticks.It's all part of a longer script but seeing as the failure occurs online 1if exists (select * from dbo.sysobjects where id =object_id(N'[dbo].[config]') and OBJECTPROPERTY(id, N'IsUserTable') =1)drop table [dbo].[config]GOThat's three lines only. Does it matter that they're in Unicode?Any ideas?Kind regards,Bruce M. AxtensSoftware EngineerStrapper Technologies
View 3 Replies
View Related
Dec 28, 2007
HiIt's my stored procedure 1 CREATE PROCEDURE singleSearch2
2 @SQ nvarchar(30),
3 @pType nvarchar(11),
4 @pCol nvarchar(11)
5 AS
6 BEGIN
7 DECLARE @SQL NVarChar(1000)
8 SELECT @SQL='SELECT *,'
9 SELECT @SQL=@SQL+' CASE RTRIM(LTRIM(op))'
10 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'e'+CHAR(39)+' THEN '+CHAR(39)+'اجاره'+ CHAR(39)
11 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'r'+CHAR(39)+' THEN '+CHAR(39)+'رهن'+CHAR(39)
12 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'f'+ CHAR(39)+' THEN '+ CHAR(39) +' Ù?روش '+CHAR(39)
13 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'e r'+CHAR(39)+' THEN '+CHAR(39)+ 'اجاره - رهن '+CHAR(39)
14 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'e f'+CHAR(39)+' THEN '+CHAR(39)+'اجاره - Ù?روش '+CHAR(39)
15 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'r f'+CHAR(39)+' THEN '+CHAR(39)+' رهن - Ù?روش '+CHAR(39)
16 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'e r f'+CHAR(39)+' THEN '+CHAR(39)+'اجاره - رهن - Ù?روش'+CHAR(39)
17 SELECT @SQL=@SQL+' ELSE op END AS xop, CASE LTRIM(RTRIM(type)) '
18 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'z -'+CHAR(39)+' THEN '+CHAR(39)+'زمین'+CHAR(39)
19 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'m -'+CHAR(39)+' THEN '+CHAR(39)+'مسکونی'+CHAR(39)
20 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'t -'+CHAR(39)+' THEN '+CHAR(39)+'تجاری'+CHAR(39)
21 SELECT @SQL=@SQL+' ELSE [type] END AS [xtype] FROM [data] '
22 SELECT @SQL=@SQL+' WHERE ([type] LIKE %'+CHAR(39)+@pType+CHAR(39)+'%) AND ('+@pCol+' LIKE %'+CHAR(39)+@SQ+CHAR(39)+'%)'
23 Exec (@SQL)
24 END
25 GO
and i face this error: Line 1: Incorrect syntax near '-'.
View 3 Replies
View Related
Jun 6, 2006
Hello All,
Me saying " has any body come across such error would be
underestimating".
Well I am getting a very peculiar and unique error "Line 1: Incorrect
syntax near 'Actions'."
Explaining you the scene is the following Stored Proc.
This stored proc is execute from a VB code in the .net application as
like: -
{Try
Connection.Init_Variables()
cn.ConnectionString = Connection.gstrConnection
ResDb.ConnectionString = Connection.gresConnection
cn.Open()
With sqlCmd
.Connection = cn
.CommandText = "DSP_Get_Required"
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@ActionId", SqlDbType.Int, 9).Value = ActionID
.Parameters("@ActionId").Direction = ParameterDirection.InputOutput
.Parameters.Add("@PersonID", SqlDbType.Int, 9).Value = PersonID
.Parameters("@PersonID").Direction = ParameterDirection.InputOutput
.Parameters.Add("@ReturnMessage", SqlDbType.VarChar, 1000).Value =
ReturnMessage.ToString
.Parameters("@ReturnMessage").Direction =
ParameterDirection.InputOutput
.Parameters.Add("@Exists", SqlDbType.Bit, 1).Value = Exists
.Parameters("@Exists").Direction = ParameterDirection.InputOutput
.Parameters.Add("@Days", SqlDbType.Int, 9).Value = 0
.Parameters("@Days").Direction = ParameterDirection.InputOutput
.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = Now()
.Parameters("@StartDate").Direction = ParameterDirection.InputOutput
.Parameters.Add("@EndDate", SqlDbType.DateTime).Value = Now()
.Parameters("@EndDate").Direction = ParameterDirection.InputOutput
.Parameters.Add("@OutCome", SqlDbType.VarChar, 20).Value = "Stop"
.Parameters("@OutCome").Direction = ParameterDirection.InputOutput
.Parameters.Add("@Evaluate", SqlDbType.Int, 9).Value = 0
.Parameters("@Evaluate").Direction = ParameterDirection.InputOutput
.Parameters.Add("@DbName", SqlDbType.VarChar, 100).Value =
ResDb.Database.ToString
.Parameters("@DbName").Direction = ParameterDirection.InputOutput
.ExecuteReader(CommandBehavior.Default)
}
On Execution I get the subjected Error "Line 1: Incorrect syntax near
'Actions'." Any Ideas from your all experience to get away from this error will be
helpful. Look forward to read somebody soon.
Stored Proc:-
{SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE ID =
OBJECT_ID(N'dbo.DSP_Get_Required_ActionS') AND OBJECTPROPERTY(id,
N'ISPROCEDURE') = 1)
DROP PROCEDURE dbo.DSP_Get_Required_ActionS
GO
CREATE PROCEDURE DSP_Get_Required_ActionS
@ActionID INT OUTPUT,
@PersonID INT OUTPUT,
@ReturnMessage Varchar(1000) OUTPUT,
@Exists BIT OUTPUT,
@Days INT OUTPUT,
@StartDate DATETIME OUTPUT,
@EndDate DATETIME OUTPUT,
@OutCome VARCHAR(20) OUTPUT,
@Evaluate INT OUTPUT,
@DbName VARCHAR(100) OUTPUT
AS
SET NOCOUNT ON
--DECLARE @PopulateSQL AS NVarchar(4000)
DECLARE @Rule_ID AS NUMERIC(9)
DECLARE @Curr_ActionSubType AS VARCHAR(20)
DECLARE @Eval_SubType AS VARCHAR(20)
-- DECLARE @OutCome AS VARCHAR(20)
-- DECLARE @Evaluate AS INT
-- DECLARE @Days AS INT
DECLARE @Message AS VARCHAR(1000)
DECLARE @Mandatory AS BIT
-- This is the variable used to interpret the Precedant subtype
DECLARE @Prec_Subtype AS VARCHAR(20)
-- DECLARE @Exists AS BIT --this is supposed to be the deceision maker
variable to be used within the precedant check.
DECLARE @Precedant_SubTypes_Cnt AS INT --This is the variable used to
recordcount the Precedant Subtypes to be checked
DECLARE @Counter AS INT -- Counter used to loop through the Table of
precedant Subtypes.
DECLARE @ROWCOUNT AS INT -- Temporary ROWCOUNT
SET @Counter = 1
--Process to retrive @Curr_ActionSubType Variable
CREATE TABLE #Curr_ActionSubType(ActionSubType VARCHAR(100))
EXEC ('INSERT INTO #Curr_ActionSubType SELECT SubType FROM '+ @DbName
+'.resadm.action WHERE '+@DbName+'.resadm.action.Actionid = '+
@ActionID+' AND ' +@DbName+'.resadm.action.status =''A''')
SET @Curr_ActionSubType = (Select ActionSubType from #Curr_ActionSubType)
DROP TABLE #Curr_ActionSubType
--Process to retrive @StartDate Variable
CREATE TABLE #StartDate(StartDate DATETIME)
EXEC('INSERT INTO #StartDate SELECT CONVERT(DATETIME,
'+@DbName+'.Resadm.Action.DateofAction + '' ''+
'+@DbName+'.Resadm.Action.TimeOfAction)
FROM '+@DbName+'.resadm.action
WHERE '+@DbName+'.resadm.action.Actionid = '+ @ActionID +' AND '+@DbName+'.resadm.action.status =''A''' )
SET @StartDate = (Select StartDate from #StartDate)
DROP TABLE #StartDate
SET @Rule_ID = (SELECT Rule_ID FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY RULE_ID)
SET @Eval_SubType = (SELECT Evaluate_Subtype FROM Rules WHERE
Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY
Evaluate_Subtype)
SET @OutCome = (SELECT OutCome FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY OutCome)
SET @Evaluate = (SELECT Evaluate FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY Evaluate)
SET @Days = (SELECT Days FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY Days)
SET @Message = (SELECT Message FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY Message)
SET @Mandatory = (SELECT Optional_Mandatory_Precedant FROM Rules WHERE
Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY
Optional_Mandatory_Precedant)
-- create the temporary table for the Subtypes to be evaluated
CREATE TABLE #Preceding_SubTypes_Details
( SubTypes_LIST_ID INT IDENTITY (1, 1) NOT NULL,
RULE_ID NUMERIC(9),
SubType VARCHAR(20),
)
-- insert the current subtype that needs to be evaluated.
INSERT INTO #Preceding_SubTypes_Details
SELECT Rule_ID, Prec_Subtype
FROM Rules_Details
WHERE Rule_ID = @Rule_ID
-- create the History table for Reference
--sk/* Modified to accomodatethe need ot dynamic database name to
retrive from the different Resman databases
CREATE TABLE #dsHistory ( ActionID INT,
PersonID INT,
ActionTypeID VARCHAR(1),
DateofAction DATETIME,
Status VARCHAR(1),
Subtype VARCHAR(6),
ActionTypeName VARCHAR(30),
ActionSubtypeID VARCHAR(6),
EffectCandidateCurrentState VARCHAR(10),
TaxCode VARCHAR(6)
)
EXEC ('INSERT INTO #dsHistory SELECT
'+@DbName+'.Resadm.Action.ActionID, '
+ @DbName+'.Resadm.Action.PersonID,
'+@DbName+'.Resadm.Action.ActionTypeID, '
+ 'CONVERT(DATETIME, '+@DbName+'.Resadm.Action.DateofAction + '' ''+
'+@DbName+'.Resadm.Action.TimeOfAction)DateofAction, '
+ @DbName+'.Resadm.Action.Status, '+@DbName+'.Resadm.Action.Subtype, '
+ @DbName+'.ResAdm.Action_Types.ActionTypeName,
'+@DbName+'.Resadm.Action_subtypes.ActionSubtypeID, '
+ @DbName+'.Resadm.Action_subtypes.EffectCandidateCurrentState,
'+@DbName+'.Resadm.Person.TaxCode '
+ ' FROM '+@DbName+'.Resadm.Action '
+ ' INNER JOIN '+@DbName+'.ResAdm.Action_Types WITH(NOLOCK) '
+ ' ON '+@DbName+'.ResAdm.Action_Types.ActionTypeID =
'+@DbName+'.Resadm.Action.ActionTypeID '
+ ' INNER JOIN '+@DbName+'.ResAdm.Action_SubTypes WITH(NOLOCK) '
+ ' ON '+@DbName+'.Resadm.Action.subtype =
'+@DbName+'.ResAdm.Action_SubTypes.actionsubtypeid '
+ ' INNER JOIN '+@DbName+'.Resadm.Person WITH(NOLOCK) '
+ ' ON '+@DbName+'.Resadm.Person.PersonID =
'+@DbName+'.Resadm.Action.PersonID '
+ ' WHERE '+@DbName+'.Resadm.Action.actionID <>
CONVERT(VARCHAR,'+@ActionID+')'
+ ' AND '+@DbName+'.Resadm.Action.PersonID =
CONVERT(VARCHAR,'+@PersonID+')'
+ ' AND '+@DbName+'.Resadm.Action.Status =''A'' '
+ 'AND (CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction +''
''+ '+@DbName+'.Resadm.Action.TimeOfAction) > '
+ ' ISNULL(( SELECT
MAX(CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction + '' ''+ '
+ @DbName+'.Resadm.Action.TimeOfAction)) '
+ ' FROM '+@DbName+'.Resadm.Action '
+ ' WHERE ('+@DbName+'.Resadm.Action.PersonID =
CONVERT(VARCHAR,'+@PersonID+')) AND '
+ ' ('+@DbName+'.Resadm.Action.Subtype =''ZERO'') '
+ ' AND ('+@DbName+'.Resadm.Action.Status=''A'')),0)) '
+ ' ORDER BY CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction +
'' ''+ '+@DbName+'.Resadm.Action.TimeOfAction )DESC, ActionID DESC')
--sk*/
SET @EndDate = (SELECT ISNULL((SELECT DateOfAction
FROM #dsHistory
WHERE SubType = @Eval_SubType), getdate()))
-- set the rowcount to retrieve the number of check to be carried out
SET @Precedant_SubTypes_Cnt = (SELECT COUNT(*) FROM
#Preceding_SubTypes_Details)
WHILE @Counter <= @Precedant_SubTypes_Cnt
BEGIN
SET @Prec_Subtype = (SELECT SubType from #Preceding_SubTypes_Details
WHERE SubTypes_LIST_ID = @Counter)
SET @ROWCOUNT = (SELECT COUNT(*) FROM #dsHistory WHERE Subtype =
@Prec_Subtype)
IF @ROWCOUNT > 0
BEGIN
SET @Exists = 1
END
IF @ROWCOUNT = 0
BEGIN
IF @Mandatory = 1
BEGIN
SET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; '
SET @Counter = @Precedant_SubTypes_Cnt
SET @Exists = 0
END
ELSE IF @Mandatory = 0
BEGIN
SET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; '
SET @Exists = @Exists
END
END
SET @Counter = @Counter+1
END
IF @Exists = 0
BEGIN
EXEC(
' UPDATE '+@DbName+'.Resadm.Action '
+ ' SET '+@DbName+'.Resadm.Action.Status = ''I'' '
+ ' WHERE '+@DbName+'.Resadm.Action.ActionID = '+@ActionID+' SET
@ReturnMessage = '+@Message
)
END
ELSE
IF @Exists = 1
BEGIN
SET @ReturnMessage = @Message
END
IF @Rule_ID = Null
BEGIN
SET @ReturnMessage = 'Validation Rule Not Present'
END
-- Select 'Exist value : ', @Exists, 'Return message is : ',
@ReturnMessage
DROP TABLE #Preceding_SubTypes_Details
DROP TABLE #dshistory
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO}
View 1 Replies
View Related
Aug 4, 2005
Hi,I'm getting the above error when i try to fill a Dataset through adataAdapter.I presume it is to do with the sql statement. Below is the relevantcode:string strPntUnitID = patientCodeLbl.Text;string strPntFName = fNameLbl.Text;string strPntLName = lNameLbl.Text;// Create DataAdapter & DatasetSqlDataAdapter daRelateDocToPnt = new SqlDataAdapter("SELECT patientNo,doctorNo FROM tblPatient" +"WHERE (pntUnitID = '"+ strPntUnitID +"') AND (pntFName = '"+strPntFName +"')"+"AND (pntLName = '"+ strPntLName +"')", conn);DataSet dsDocNoToPnt = new DataSet();// Create command builder, automatically generates the update commandsSqlCommandBuilder pntCmd = new SqlCommandBuilder(daRelateDocToPnt);// Set the MissingSchemaAction property to AddWithKey because Fill willnot cause primary// key & unique key information to be retrieved unless AddWithKey isspecified.daRelateDocToPnt.MissingSchemaAction = MissingSchemaAction.AddWithKey;// Use dataAdapter to fill DataSetdaRelateDocToPnt.Fill(dsDocNoToPnt, "Patient");// place intDocNo into the dataset schemadsDocNoToPnt.Tables["Patient"].Rows[0]["doctorNo"] = "intDocNo";// Update The DatabasedaRelateDocToPnt.Update(dsDocNoToPnt, "Patient");Can anyone spot the problem?Thanks
View 3 Replies
View Related
Jun 6, 2006
Hello All,Me saying " has any body come across such error would beunderestimating".Well I am getting a very peculiar and unique error "Line 1: Incorrectsyntax near 'Actions'."Explaining you the scene is the following Stored Proc.This stored proc is execute from a VB code in the .net application aslike: -{TryConnection.Init_Variables()cn.ConnectionString = Connection.gstrConnectionResDb.ConnectionString = Connection.gresConnectioncn.Open()With sqlCmd..Connection = cn..CommandText = "DSP_Get_Required".CommandType = CommandType.StoredProcedure..Parameters.Add("@ActionId", SqlDbType.Int, 9).Value = ActionID..Parameters("@ActionId").Direction = ParameterDirection.InputOutput..Parameters.Add("@PersonID", SqlDbType.Int, 9).Value = PersonID..Parameters("@PersonID").Direction = ParameterDirection.InputOutput..Parameters.Add("@ReturnMessage", SqlDbType.VarChar, 1000).Value =ReturnMessage.ToString..Parameters("@ReturnMessage").Direction =ParameterDirection.InputOutput..Parameters.Add("@Exists", SqlDbType.Bit, 1).Value = Exists..Parameters("@Exists").Direction = ParameterDirection.InputOutput..Parameters.Add("@Days", SqlDbType.Int, 9).Value = 0..Parameters("@Days").Direction = ParameterDirection.InputOutput..Parameters.Add("@StartDate", SqlDbType.DateTime).Value = Now()..Parameters("@StartDate").Direction = ParameterDirection.InputOutput..Parameters.Add("@EndDate", SqlDbType.DateTime).Value = Now()..Parameters("@EndDate").Direction = ParameterDirection.InputOutput..Parameters.Add("@OutCome", SqlDbType.VarChar, 20).Value = "Stop"..Parameters("@OutCome").Direction = ParameterDirection.InputOutput..Parameters.Add("@Evaluate", SqlDbType.Int, 9).Value = 0..Parameters("@Evaluate").Direction = ParameterDirection.InputOutput..Parameters.Add("@DbName", SqlDbType.VarChar, 100).Value =ResDb.Database.ToString..Parameters("@DbName").Direction = ParameterDirection.InputOutput..ExecuteReader(CommandBehavior.Default)}On Execution I get the subjected Error "Line 1: Incorrect syntax near'Actions'."Any Ideas from your all experience to get away from this error will behelpful. Look forward to read somebody soon.Stored Proc:-{SET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS OFFGOIF EXISTS (SELECT * FROM dbo.sysobjects WHERE ID =OBJECT_ID(N'dbo.DSP_Get_Required_ActionS') AND OBJECTPROPERTY(id,N'ISPROCEDURE') = 1)DROP PROCEDURE dbo.DSP_Get_Required_ActionSGOCREATE PROCEDURE DSP_Get_Required_ActionS@ActionID INT OUTPUT,@PersonID INT OUTPUT,@ReturnMessage Varchar(1000) OUTPUT,@Exists BIT OUTPUT,@Days INT OUTPUT,@StartDate DATETIME OUTPUT,@EndDate DATETIME OUTPUT,@OutCome VARCHAR(20) OUTPUT,@Evaluate INT OUTPUT,@DbName VARCHAR(100) OUTPUTASSET NOCOUNT ON--DECLARE @PopulateSQL AS NVarchar(4000)DECLARE @Rule_ID AS NUMERIC(9)DECLARE @Curr_ActionSubType AS VARCHAR(20)DECLARE @Eval_SubType AS VARCHAR(20)-- DECLARE @OutCome AS VARCHAR(20)-- DECLARE @Evaluate AS INT-- DECLARE @Days AS INTDECLARE @Message AS VARCHAR(1000)DECLARE @Mandatory AS BIT-- This is the variable used to interpret the Precedant subtypeDECLARE @Prec_Subtype AS VARCHAR(20)-- DECLARE @Exists AS BIT --this is supposed to be the deceision makervariable to be used within the precedant check.DECLARE @Precedant_SubTypes_Cnt AS INT--This is the variable used torecordcount the Precedant Subtypes to be checkedDECLARE @Counter AS INT -- Counter used to loop through the Table ofprecedant Subtypes.DECLARE @ROWCOUNT AS INT -- Temporary ROWCOUNTSET @Counter = 1--Process to retrive @Curr_ActionSubType VariableCREATE TABLE #Curr_ActionSubType(ActionSubType VARCHAR(100))EXEC ('INSERT INTO #Curr_ActionSubType SELECT SubType FROM '+ @DbName+'.resadm.action WHERE '+@DbName+'.resadm.action.Actionid = '+@ActionID+' AND ' +@DbName+'.resadm.action.status =''A''')SET @Curr_ActionSubType = (Select ActionSubType from#Curr_ActionSubType)DROP TABLE #Curr_ActionSubType--Process to retrive @StartDate VariableCREATE TABLE #StartDate(StartDate DATETIME)EXEC('INSERT INTO #StartDate SELECT CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction + '' ''+'+@DbName+'.Resadm.Action.TimeOfAction)FROM '+@DbName+'.resadm.actionWHERE '+@DbName+'.resadm.action.Actionid = '+ @ActionID +' AND'+@DbName+'.resadm.action.status =''A''')SET @StartDate = (Select StartDate from #StartDate)DROP TABLE #StartDateSET @Rule_ID = (SELECT Rule_ID FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY RULE_ID)SET @Eval_SubType = (SELECT Evaluate_Subtype FROM Rules WHERECurr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BYEvaluate_Subtype)SET @OutCome = (SELECT OutCome FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY OutCome)SET @Evaluate = (SELECT Evaluate FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY Evaluate)SET @Days = (SELECT Days FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY Days)SET @Message = (SELECT Message FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY Message)SET @Mandatory = (SELECT Optional_Mandatory_Precedant FROM Rules WHERECurr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BYOptional_Mandatory_Precedant)-- create the temporary table for the Subtypes to be evaluatedCREATE TABLE #Preceding_SubTypes_Details(SubTypes_LIST_ID INT IDENTITY (1, 1) NOT NULL,RULE_ID NUMERIC(9),SubType VARCHAR(20),)-- insert the current subtype that needs to be evaluated.INSERT INTO #Preceding_SubTypes_DetailsSELECT Rule_ID, Prec_SubtypeFROM Rules_DetailsWHERE Rule_ID = @Rule_ID-- create the History table for Reference--sk/*Modified to accomodatethe need ot dynamic database name toretrive from the different Resman databasesCREATE TABLE #dsHistory ( ActionID INT,PersonID INT,ActionTypeID VARCHAR(1),DateofAction DATETIME,Status VARCHAR(1),Subtype VARCHAR(6),ActionTypeName VARCHAR(30),ActionSubtypeID VARCHAR(6),EffectCandidateCurrentState VARCHAR(10),TaxCode VARCHAR(6))EXEC ('INSERT INTO #dsHistory SELECT'+@DbName+'.Resadm.Action.ActionID, '+ @DbName+'.Resadm.Action.PersonID,'+@DbName+'.Resadm.Action.ActionTypeID, '+ 'CONVERT(DATETIME, '+@DbName+'.Resadm.Action.DateofAction + '' ''+'+@DbName+'.Resadm.Action.TimeOfAction)DateofActio n, '+ @DbName+'.Resadm.Action.Status, '+@DbName+'.Resadm.Action.Subtype, '+ @DbName+'.ResAdm.Action_Types.ActionTypeName,'+@DbName+'.Resadm.Action_subtypes.ActionSubtypeID , '+ @DbName+'.Resadm.Action_subtypes.EffectCandidateCu rrentState,'+@DbName+'.Resadm.Person.TaxCode '+ ' FROM '+@DbName+'.Resadm.Action '+ ' INNER JOIN '+@DbName+'.ResAdm.Action_Types WITH(NOLOCK) '+ ' ON '+@DbName+'.ResAdm.Action_Types.ActionTypeID ='+@DbName+'.Resadm.Action.ActionTypeID '+ ' INNER JOIN '+@DbName+'.ResAdm.Action_SubTypes WITH(NOLOCK) '+ ' ON '+@DbName+'.Resadm.Action.subtype ='+@DbName+'.ResAdm.Action_SubTypes.actionsubtypeid '+ ' INNER JOIN '+@DbName+'.Resadm.Person WITH(NOLOCK) '+ ' ON '+@DbName+'.Resadm.Person.PersonID ='+@DbName+'.Resadm.Action.PersonID '+ ' WHERE '+@DbName+'.Resadm.Action.actionID <>CONVERT(VARCHAR,'+@ActionID+')'+ ' AND '+@DbName+'.Resadm.Action.PersonID =CONVERT(VARCHAR,'+@PersonID+')'+ ' AND '+@DbName+'.Resadm.Action.Status =''A'' '+ 'AND (CONVERT(DATETIME,'+@DbName+'.Resadm.Action.Dateof Action +''''+ '+@DbName+'.Resadm.Action.TimeOfAction) > '+ ' ISNULL(( SELECTMAX(CONVERT(DATETIME,'+@DbName+'.Resadm.Action.Dat eofAction + '' ''+ '+ @DbName+'.Resadm.Action.TimeOfAction)) '+ ' FROM '+@DbName+'.Resadm.Action '+ ' WHERE ('+@DbName+'.Resadm.Action.PersonID =CONVERT(VARCHAR,'+@PersonID+')) AND '+ ' ('+@DbName+'.Resadm.Action.Subtype =''ZERO'') '+ ' AND ('+@DbName+'.Resadm.Action.Status=''A'')),0)) '+ ' ORDER BY CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofA ction +'' ''+ '+@DbName+'.Resadm.Action.TimeOfAction )DESC, ActionID DESC')--sk*/SET @EndDate = (SELECT ISNULL((SELECT DateOfActionFROM #dsHistoryWHERE SubType = @Eval_SubType), getdate()))-- set the rowcount to retrieve the number of check to be carried outSET @Precedant_SubTypes_Cnt = (SELECT COUNT(*) FROM#Preceding_SubTypes_Details)WHILE @Counter <= @Precedant_SubTypes_CntBEGINSET @Prec_Subtype = (SELECT SubType from #Preceding_SubTypes_DetailsWHERE SubTypes_LIST_ID = @Counter)SET @ROWCOUNT = (SELECT COUNT(*) FROM #dsHistory WHERE Subtype =@Prec_Subtype)IF @ROWCOUNT > 0BEGINSET @Exists = 1ENDIF @ROWCOUNT = 0BEGINIF @Mandatory = 1BEGINSET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; 'SET @Counter = @Precedant_SubTypes_CntSET @Exists = 0ENDELSE IF @Mandatory = 0BEGINSET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; 'SET @Exists = @ExistsENDENDSET @Counter = @Counter+1ENDIF @Exists = 0BEGINEXEC(' UPDATE '+@DbName+'.Resadm.Action '+ ' SET '+@DbName+'.Resadm.Action.Status = ''I'' '+ ' WHERE '+@DbName+'.Resadm.Action.ActionID = '+@ActionID+' SET@ReturnMessage = '+@Message)ENDELSEIF @Exists = 1BEGINSET @ReturnMessage = @MessageENDIF @Rule_ID = NullBEGINSET @ReturnMessage = 'Validation Rule Not Present'END-- Select 'Exist value : ', @Exists, 'Return message is : ',@ReturnMessageDROP TABLE #Preceding_SubTypes_DetailsDROP TABLE #dshistoryGOSET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS ONGO}
View 1 Replies
View Related
May 30, 2007
Hi Marc,
I have a similar problem as mentioned in the first mail of this chain. I am getting Line 202:Incorrect syntax near 'end'" while I try to execute the procedure from my VC++ code using
ExecuteNonQuery method.
can you guide me about solving this issue?
Regards,
Anni
View 2 Replies
View Related
Sep 13, 2006
Hi,
Uses: Sql server 2000, asp.net 1.1;
I've the following Stored Procedure:
<SQL Code>
CREATE PROCEDURE PABX_sp_MyPABX_ShowExtWatch
@FromDate DATETIME,
@ToDate DATETIME,
@PortalID INT = 1,
@UserID INT
AS
SELECT PABX_Ext_Watch.ExtNo As ExtNo, COUNT(*) AS Calls, SUM(PABX_Calls.Rate) AS NetAmt
FROM PABX_Ext_Watch
INNER JOIN PABX_Calls
ON PABX_Ext_Watch.ExtNo = PABX_Calls.ExtNo
INNER JOIN PABX_PortalUsers
ON PABX_Ext_Watch.PortalUserID = PABX_PortalUsers.PortalUserID
AND PABX_Calls.PortalID = PABX_PortalUsers.PortalID
WHERE PABX_Calls.sTime >= CONVERT(DATETIME, @FromDate, 102)
AND PABX_Calls.eTime <= CONVERT(DATETIME, @ToDate, 102)
AND PABX_PortalUsers.uID = @UserID
AND PABX_PortalUsers.PortalID = @PortalID
GROUP BY PABX_Ext_Watch.ExtNo
GO
</SQL Code>
However if I execute this stored procedure in asp.net I get the following error, despite the stored procedure executed successfully in query analyzer:
Line 1: Incorrect Syntax Near ......
When I check the sql profiler the stored procedure is been executed in this way:
exec sp_executesql N'PABX_sp_MYPABX_ShowExtWatch', N'@FromDate datetime,@ToDate datetime,@UserID int,@PortalID int', @FromDate = 'Sep 1 2006 12:00:00:000AM', @ToDate = 'Sep 30 2006 12:00:00:000AM', @UserID = 207, @PortalID = 2
I couldn't figure it out though sql server management console and query analyzer showed no signs of errors. I sense that the sql is not being executed correctly with letters as "N" in the sql profiler.
Could anyone help me out on this?
Thanks & Regards,
View 6 Replies
View Related
Jul 29, 2006
what am i doing wrong.. :(
CREATE PROCEDURE getlistofspclass(@date datetime,@s varchar(8000) output)
AS
select @s = coalesce(@s + ' & ', '') + '"' + convert(varchar(10),dbo.calader.timestart)+ ' ' + dbo.classT.classname + '<p>'FROM dbo.calader INNER JOIN dbo.classT ON dbo.calader.classid = dbo.classT.classcodeWHERE dbo.calader.caledardatedates = @dateexec( @s)GO
View 6 Replies
View Related
Mar 4, 2004
Hi;
I am trying to prepare a login page.My code first controls if user exists in database with GetUser stored procedure then if he/she exists getting the roles assigned to that user with GetUserRoles procedure but I am taking this error
Line 1: Incorrect syntax near 'GetUserRoles'.
GetUserRoles Procedure:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER Procedure GetUserRoles
(
@UserName char(10),
@Roles char(10) Output
)
As
Select @Roles=RoleID From UserRoles Where
UserID=@UserName
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
My ASP.NET Code:
.......................
SqlParameter SQLParm=new SqlParameter();
SQLStr=new SqlCommand("GetUser",Con.GetConnection);
SQLStr.CommandType=CommandType.StoredProcedure;
SQLParm=SQLStr.Parameters.Add("ReturnValue",SqlDbType.Int);
SQLParm.Direction=ParameterDirection.ReturnValue;
SQLStr.Parameters.Add("@UserName",txtuser.Text);
SQLStr.Parameters.Add("@Pass",txtpass.Text);
Con.GetConnection.Open();
SQLStr.ExecuteNonQuery();
Returned=Convert.ToInt32(SQLStr.Parameters["ReturnValue"].Value);
if(Returned==1)
{
SQLStr=new SqlCommand("GetUserRoles",Con.GetConnection);
SQLStr.Parameters.Add("@UserName",txtuser.Text);
SQLParm=SQLStr.Parameters.Add("@Roles",SqlDbType.Char);
SQLParm.Size=50;
SQLParm.Direction=ParameterDirection.Output;
SQLStr.ExecuteNonQuery();
Roles=Convert.ToString(SQLStr.Parameters["@Roles"].Value);
LblMsg.Text=Roles;
Con.GetConnection.Close();
}
............................
............................
Thank you for your replies from now....
View 6 Replies
View Related
Mar 30, 2000
I am confused. Any help you can provide, to resolve this error, would be very appreciated...... Thanks in advance!!
I am getting this error message......
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '-'.
/formstoday/issue_log-preview.asp, line 76
The code for line 76 is thus......
objConn.execute sql
Here is the code gor the asp page........
<%
Dim StrEmail
Dim StrName
Dim StrIssue
StrEmail=request.form("email")
StrName=request.form("name")
StrIssue=request.form("issue")
Set objConn = Server.CreateObject("ADODB.Connection")
Set rs = server.createobject("ADODB.Recordset")
objConn.open "Driver={SQL server};Server=document;DSN=SQL;Database=issues;UI D=steu;PWD;"
sql = "Insert into issue-log2 (name,email,issue) values('" & _
strName & "','" & _
strEmail & "','" & _
StrIssue & "')"
objConn.execute sql
%>
Steu
View 2 Replies
View Related
Feb 29, 2008
Here is a Database script I wrote: I can't figure out what the problem is when I declare my primary Keys in the second and third table.
Thanks in Advance
Errors:
Msg 156, Level 15, State 1, Line 19
Incorrect syntax near the keyword 'IDENTITY'.
Msg 156, Level 15, State 1, Line 29
Incorrect syntax near the keyword 'IDENTITY'.
CREATE DATABASE GoGreen
Go
USE GoGreen
Create TABLE Student
(StudentID INT NOT NULL IDENTITY PRIMARY KEY, <---no Error here
DrivePassCode char(3) NOT NULL,
LName varchar(50) NOT NULL,
FName varchar(50) NOT NULL,
Address1 varchar(50) NOT NULL,
Address2 varchar(50) NULL,
City varchar(50) NOT NULL,
PostalCode varchar(20) NOT NULL,
PhoneNumber varchar(50) NOT NULL,
Email varchar(50) NOT NULL,
Smoker char(2) NOT NULL,
NearestCityOrTown varchar(50) NOT NULL,
PaymentType varchar(20) NOT NULL,)
CREATE TABLE CoordinatedRideShare
(RideID INT NOT NULL, IDENTITY PRIMARY KEY, <---Error #1
StudentID INT NOT NULL REFERENCES Student(StudentID)
[ON DELETE {CASCADE}]
[ON UPDATE {CASCADE}],
M-W ARRIVAL TIME smalldatetime NOT NULL,
M-W DEPART TIME smalldatetime NOT NULL,
T-TH ARRIVAL TIME smalldatetime NOT NULL,
T-TH DEPART TIME smalldatetime NOT NULL,)
CREATE TABLE MeetingLocation
(LocationID INT NOT NULL, IDENTITY PRIMARY KEY AUTONUMBER, <---Error#2
RideID INT NOT NULL REFERENCES Coordinated RideShare(RideID)
[ON DELETE {CASCADE}]
[ON UPDATE {CASCADE}],
House Pickup char(1) NULL,
General meeting place varchar(50) NULL,)
CREATE INDEX DrivePass
ON Student (DrivePass)
CREATE INDEX NearestCityOrTown
ON Sudent (NearestCityOrTown)
View 9 Replies
View Related
Nov 17, 2007
Hello,
Can anybody help me with this error , System.Data.SqlClient.SqlException. "Line 1: Incorrect Syntax near :'m' ."
I have a textbox named DESCRIPTION and am trying to insert the values entered by user in this textbox.
It works well if a user types " I am unable to " but it throws this error when a user types " I'm unable to "...because of I'm ..
How do i fix this?
My Query:
strSQL = "Insert into ABC(DESCRIPTION) values('" & strDescription & "')"
When i try below query in query analyser , am getting this error ....
Error 1: [Line 1: Incorrect syntax near 'm'.]
Error 2: [ Unclosed quotation mark before the character string '.]
update ABC set DESCRIPTION = 'I'm unable' WHERE ABC_ID = '142'
Thanks to reply.
View 4 Replies
View Related
Sep 17, 2007
I am getting an error saying, "Incorrect syntax near keyword 'ON'" Could someone please help? Here is my code:
str = "SELECT FAC_REQUEST.*, StateFAC.*, STATUS.sStatus, FAC_TYPE.Facility_Type FROM FAC_TYPE INNER JOIN ((FAC_REQUEST INNER JOIN STATUS ON FAC_REQUEST.iStatusID = STATUS.iStatusID) ON StateFAC.DVN = FAC_REQUEST.DVN) ON FAC_TYPE.Faciltiy_Type = FAC.FacilityType WHERE iRequestID=" & iRequestID
Thanks
View 6 Replies
View Related
Mar 7, 2008
Hi,
When i exceute my report i get the following .. An error occured during local report processing. Query exceuteion failed for dataset 'orders' Incorrect syntax near ')'
If i give NULL i get the above error... But if give one or 2 values it works. but If I run the query in my Sql server mgt studio it works fine too and i run in the BIDS or VS2005 it works fine.. but something happens when i generate the reports... ALTER Procedure [dbo].[usp_GetOrdersByOrderDate]
@ClientId nvarchar(max)= NULL,
@StartDate datetime,
@EndDate datetime
AS
Declare @SQLTEXT nvarchar(max)
If @ClientId IS NULL
Begin
Select
o.OrderId,
o.OrderDate,
o.CreatedByUserId,
c.LoginId,
o.Quantity,
o.RequiredDeliveryDate,
cp.PlanId,
cp.ClientPlanId
FROM
[Order] o
Inner Join ClientPlan cp on o.PlanId = cp.PlanId
Inner Join ClientUser c on o.CreatedByUserId = c.UserId
WHERE
--cp.ClientId = @ClientId
--AND
o.OrderDate BETWEEN @StartDate AND @EndDate
ORDER BY
o.OrderId DESC
END
ELSE
BEGIN
SELECT @SQLTEXT = 'Select
o.OrderId,
o.OrderDate,
o.CreatedByUserId,
c.LoginId,
o.Quantity,
o.RequiredDeliveryDate,
cp.PlanId,
cp.ClientPlanId
FROM
[Order] o
Inner Join ClientPlan cp on o.PlanId = cp.PlanId
Inner Join ClientUser c on o.CreatedByUserId = c.UserId
WHERE
cp.ClientId in (' + @ClientId + ')
AND
o.OrderDate BETWEEN ' + Convert(varchar,@StartDate) + ' AND ' + convert(varchar, @EndDate) + '
ORDER BY
o.OrderId DESC'
execute (@SQLTEXT)
END
any help will be appreciated.
Regards
Karen
View 13 Replies
View Related
Jan 14, 2005
Hi! I need some help with this error which I'm unable to understand.
Any help will be highly appreciated.
<Error>
Line 1: Incorrect syntax near 'Number'.
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 'Number'.
Source Error:
Line 69: Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Line 70: Dim ds As DataSet = New DataSet
Line 71: da.Fill(ds, "Equip")
Line 72:
Line 73: dgdSearch.DataSource = ds.Tables("Equip").DefaultView
Source File: c:inetpubwwwrootEquip logDemoWebForm3.aspx.vb Line: 71
Stack Trace:
[SqlException: Line 1: Incorrect syntax near 'Number'.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
Demo.WebForm3.butSearch_Click(Object sender, EventArgs e) in c:inetpubwwwrootEquip logDemoWebForm3.aspx.vb:71
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain() +1292
</Error>
Private Sub butSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butSearch.Click
Dim objConnection As SqlConnection
Dim objCommand As SqlCommand
Dim objAdapter As SqlDataAdapter
Dim objDataReader As SqlDataReader
Dim objDataSet As DataSet
Dim strSearch As String
Dim StrSQLQuery As String
'Dim mySQL As String
'Get Search
strSearch = txtSearch.Text
'If there's nothing to search for then don't search
' o/w build our SQL Query execute it.
If Len(Trim(strSearch)) > 0 Then
'Set up our connection.
Dim strConn As String = ("server=(local);Integrated Security=SSPI;database=Equipment Log")
'-- setup the select command
Dim mySQL As String = "Select * From Equip Where " & ddlSearch.SelectedValue.ToString() & " Like '" & txtSearch.Text & " %' Order by DemoNum"
Dim MyConn As New SqlConnection(strConn)
'--create the SqlCommand object (a connection would need to be set up too)
Dim cmd As SqlCommand = New SqlCommand(mySQL, MyConn)
MyConn.Open()
'--execute the query and fill a dataset with the results
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim ds As DataSet = New DataSet
da.Fill(ds, "Equip")
dgdSearch.DataSource = ds.Tables("Equip").DefaultView
'Create new command object passing it our SQL Query
'and telling it which connection to use.
objCommand = New SqlCommand(strSearch, objConnection)
'DataBind DG to DS
ddlSearch.DataBind()
dgdSearch.DataBind()
MyConn.Close()
Else
txtSearch.Text = "Enter Serach Here"
End If
View 1 Replies
View Related
Jan 2, 2006
I am getting the following error when attempting to call a certain function:
"Incorrect Syntax near spListPrograms, Line 1"
Here is the sproc:
ALTER PROCEDURE spListPrograms
@parentID int = 0
AS
SELECT pwbsID, pwbsTitle FROM ProgramWBS WHERE pwbsParent = @parentID
It is being called from this function:
Public Shared Function ListProgramChildNodes(Optional ByVal parentID As Integer = 0) As SqlDataReader
Dim cmd As New SqlCommand("spListPrograms", strConn)
cmd.Parameters.AddWithValue("@parentID", parentID)
Try
strConn.Open()
Return cmd.ExecuteReader(CommandBehavior.CloseConnection)
Catch e As SqlException
Dim errorMessages As String = ""
Dim i As Integer
For i = 0 To e.Errors.Count - 1
errorMessages += "Index #" & i.ToString() & ControlChars.NewLine _
& "Message: " & e.Errors(i).Message & ControlChars.NewLine _
& "LineNumber: " & e.Errors(i).LineNumber & ControlChars.NewLine _
& "Source: " & e.Errors(i).Source & ControlChars.NewLine _
& "Procedure: " & e.Errors(i).Procedure & ControlChars.NewLine
Next i
MsgBox(errorMessages)
Finally
strConn.Close()
End Try
End Function
The sproc works just fine when I execute it from the database directly in SQl Express. What could cause an incorrect syntax error? There's hardly any syntax there for an error to occur Thanks for any help you can give me.
View 2 Replies
View Related
Mar 8, 2004
hi. i am relatively new to sql. i am wondering how to resolve my "incorrect syntax error" on an IP Address string i am trying to add.
the table has IPAddress as data type "text" and length 16 (which won't let me change the length). It seems that sql is looking for a data type with no more than one decimal (money, float, etc). How do i resolve this? thanks in advance. Peter
View 7 Replies
View Related
Jan 16, 2008
Hi i have the following code in my sql database;CASE dbo.tblWorkSchedule.WorkScheduleType_ID WHEN 1 THENCASE IsNull(dbo.tblSurvey.WorkScheduleOverallStatus_ID,0) WHEN 4 THENdbo.tblWorkSchedule.UpliftedRate ELSE dbo.GetSWT_PropertyYearPeriodRate (IsNull(tblRateSchedule.WorkType_ID,0) ,tblWorkSchedule.WorkSchedule_ID , tblSurvey.PropertyYear_ID , tblSurvey.PropertyPeriod_ID ) END I want to add the following lines to it, however it gives me an error "Error 156: Incorrect syntax near the keyword "WHEN". What do i need to do, thank you. WHEN 3 THEN dbo.tblWorkSchedule.UpliftedRate ELSE dbo.GetSWT_PropertyYearPeriodRate (IsNull(tblRateSchedule.WorkType_ID,0) ,tblWorkSchedule.WorkSchedule_ID , tblSurvey.PropertyYear_ID , tblSurvey.PropertyPeriod_ID ) END
View 7 Replies
View Related
Feb 28, 2008
Hi,
I am building a website and database system for a university project, and am getting an error message when inserting data to a table (error message = "System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'."). I would be most grateful if anybody could point out where I am going wrong! My code is;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
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 System.Xml.Linq;
public partial class Default2 : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e)
{if ((Session["sUserName"]) == null)
{Response.Redirect("Default.aspx");
}
else
{Convert.ToString(Session["sUserName"]);
}
}protected void Register(object sender, EventArgs e)
{
//Create the ConnectionSqlConnection sqlConn =
new SqlConnection("server=Acer-Laptop\SQLEXPRESS; database=NeuCar; Trusted_Connection=true");
//Open the connection
sqlConn.Open();
//Create the Command, passing in the SQL statement and the ConnectionString queryString = "INSERT INTO Member (FirstName, LastName, Title, Email, AddressLine1, AddressLine2, TownOrCity, County, Postcode) VALUES(@myFirstName, @myLastName, @myTitle, @myEmail, @myAddressLine1, @myAddressLine2, @myTownOrCity, @myCounty, @myPostcode) WHERE Member (UserName = @myUserName); ";
SqlCommand cmd = new SqlCommand(queryString, sqlConn);cmd.Parameters.Add(new SqlParameter("@myUserName", Session["sUserName"]));
cmd.Parameters.Add(new SqlParameter("@myFirstName", FirstNameTextBox.Text));cmd.Parameters.Add(new SqlParameter("@myLastName", LastNameTextBox.Text));
cmd.Parameters.Add(new SqlParameter("@myTitle", TitleTextBox.Text));cmd.Parameters.Add(new SqlParameter("@myEmail", ConfirmEmailTextBox.Text));
cmd.Parameters.Add(new SqlParameter("@myAddressLine1", AddressLine1TextBox.Text));cmd.Parameters.Add(new SqlParameter("@myAddressLine2", AddressLine2TextBox.Text));
cmd.Parameters.Add(new SqlParameter("@myTownOrCity", TownOrCityTextBox.Text));cmd.Parameters.Add(new SqlParameter("@myCounty", CountyTextBox.Text));cmd.Parameters.Add(new SqlParameter("@myPostcode", PostcodeTextBox.Text));
cmd.ExecuteNonQuery();
Response.Redirect("Register.aspx");
//Close the connection
sqlConn.Close();
}
}
Also, is this line of code correct for passing a session variable into a parameter?;
cmd.Parameters.Add(new SqlParameter("@myUserName", Session["sUserName"]));
Many thanks for your time and help!
Chima
View 5 Replies
View Related
May 10, 2000
I am moving along but I still get this pesky error. In a field on the user form for comments - when there is a ' character - I get this syntax error. But, I have removed the ' character with this code:
fieldname= Replace(Request.Form("fieldname"), "'", " ")
So how do I get rid of this error? Beats me.
Anyone know of resources I can read about this?
Thanks in advance...................
Set objConn = Server.CreateObject("ADODB.Connection")
Set rs = server.createobject("ADODB.Recordset")
objConn.open "Driver={SQL Server};Server=server;DSN=SQL3;Database=requests;U ID=probe;PWD=;"
strDocument= request.form("qryName")
strName= request.form("name")
strDescription= request.form("description")
strEmail= request.form("email")
StrTeam= request.form("shift")
StrSection= request.form("pickone")
StrComments= request.form("comments")
StrDatein= request.form("datein")
StrType= request.form("type")
StrDcfnumber=CounterHits
sql = "Insert into dcf_submit (qryName,name,description,email_requestor,shift,se ction_pickone,change_type,comments,date_submit,dcf _number) values('" & _
strDocument & "','" & _
strName & "','" & _
strDescription & "','" & _
strEmail & "','" & _
StrTeam & "','" & _
StrSection & "','" & _
StrType & "','" & _
StrComments & "','" & _
StrDatein & "','" & _
StrDcfnumber & "')"
objConn.execute sql
rs.Close
Set rs = Nothing
View 1 Replies
View Related
Mar 14, 2012
----change In the name of Table 5 Table 6
Use test
GO
ALTER TABLE NAME tablo5 RENAME TO tablo6;
GO
but error messages::
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'tablo5'.
------------------
------------------
----tablo4 d1 ==> d11 change.
Use test
GO
ALTER TABLE tablo4 RENAME COLUMN d1 TO d11;
GO
error messages::
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'RENAME'
View 1 Replies
View Related
Nov 12, 2014
I am getting error "Incorrect syntax near the keyword 'else'"
below is my code
declare @a varchar(15), @b Float(12) ,@c Float(12),@m varchar(15),@n Float(15),@av Float(15),@xav float(15)
SELECT @a=reverse(Substring(reverse(remarks),Charindex('tS',REVERSE(remarks))+2,4))
FROM [IVRS_MIS].[dbo].[logs] where app_name='IVFRT_POC' and remarks like '%answered%'
if @a = 1020
SELECT @m = '1022', @n = Count(@a), @av = Count(@a)/4.0 ,@b = substring(MAX(right(node_info, charindex('X',reverse(node_info))-8)),1,5) ,@c=substring(MIN(right(node_info, charindex('X',reverse(node_info))-8)),1,5),@xav=(@b+@c)/2.0
FROM [IVRS_MIS].[dbo].[logs]
[code].....
View 2 Replies
View Related
Jul 12, 2007
Hey guys, I'm getting this really strange incorrect sytax error with a program I'm writing in VB.NET for an ASP.NET website.
Here is my code:
Dim mySelectQuery2 As String = "SELECT MAX(TicketID) FROM tblTicket"
Dim myInsertQuery As String = "INSERT INTO tblCaller (TicketID)"
Dim myConnection As New Data.SqlClient.SqlConnection(myConnString)
Dim myCommand As New Data.SqlClient.SqlCommand(mySelectQuery2, myConnection)
Dim myCommand2 As New Data.SqlClient.SqlCommand(myInsertQuery, myConnection)
Dim retvalue As Integer
myConnection.Open()
retvalue = myCommand2.ExecuteNonQuery()
Console.WriteLine(retvalue)
Dim myReader2 As Data.SqlClient.SqlDataReader
myReader2 = myCommand.ExecuteReader()
myReader2.Close()
myConnection.Close()
Now, the actual error I'm getting is "Incorrect syntax near ')'." that is refering to the link of code "retvalue = myCommand2.ExecuteNonQuery()". I've played around with the code a little bit but I just can't seem to make that error go away.
My only guess is that in the "myInsertQuery" I should have "VALUE (...", but I'm not sure what to put there.
If anyone could make any suggestions on what I might want to try, or if you think that you need more information please let me know.
Thanks,
aqzman
View 5 Replies
View Related
Feb 6, 2007
Hi all,
I use
="<Query><XmlData>" & Parameters!XMLData.Value & "</XmlData><ElementPath>Product {@}</ElementPath></Query>"
and I enter XMLData with value "<Products><Product>Chair</Product><Product>Table</Product></Products>"
for the query expression of the dataset, and I always got error:
Query failed for dataset "Dataset1"
Incorrect syntax near '<'
What's wrong with it?
Thanks,
Jone
View 1 Replies
View Related
Mar 10, 2008
Hi,
When i exceute my report i get the following .. An error occured during local report processing. Query exceuteion failed for dataset 'orders' Incorrect syntax near ')'
If i give NULL i get the above error... But if give one or 2 values it works. but If I run the query in my Sql server mgt studio it works fine too and i run in the BIDS or VS2005 it works fine.. but something happens when i generate the report in preview mode. I am using multivalue parameter
This is my sproc
Code Snippet
ALTER Procedure [dbo].[usp_GetOrdersByOrderDate]
@StartDate datetime,
@EndDate datetime,
@ClientId nvarchar(max)= NULL
AS
Declare @SQLTEXT nvarchar(max)
if @ClientId is NULL
BEGIN
SELECT
o.OrderId,
o.OrderDate,
o.CreatedByUserId,
c.LoginId,
o.Quantity,
o.RequiredDeliveryDate,
cp.PlanId,
cp.ClientPlanId
--c.ClientId
FROM
[Order] o
Inner Join ClientPlan cp on o.PlanId = cp.PlanId and o.CreatedByUserId = cp.UserId
Inner Join ClientUser c on o.CreatedByUserId = c.UserId
WHERE
--cp.ClientId = @ClientId
--AND
o.OrderDate BETWEEN @StartDate AND @EndDate
ORDER BY
o.OrderId DESC
END
ELSE
BEGIN
SELECT @SQLTEXT = 'Select
o.OrderId,
o.OrderDate,
o.CreatedByUserId,
c.LoginId,
o.Quantity,
o.RequiredDeliveryDate,
cp.PlanId,
cp.ClientPlanId
--cp.ClientId
FROM
[Order] o
Inner Join ClientPlan cp on o.PlanId = cp.PlanId --AND cp.ClientId in ('+ convert(Varchar, @ClientId) + ' )
Inner Join ClientUser c on o.CreatedByUserId = c.UserId
WHERE
cp.ClientId in (' + convert(Varchar,@ClientId) + ')
AND
o.OrderDate BETWEEN ''' + Convert(varchar, @StartDate) + ''' AND ''' + convert(varchar, @EndDate) + '''
ORDER BY
o.OrderId DESC'
exec(@SQLTEXT)
END
any help will be appreciated..
Thanks
Karen
View 14 Replies
View Related
Sep 18, 2007
Hi I am using JDBC driver version "1.0.809.102". In the ms sqlserver 2000 database I am acessing there is a table named as "CDR_DATA_2007-09-12". When I run the following query "select * from CDR_DATA_2007-09-12" i get the following exception. Please help me out to solve this problem.
com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: Incorrect syntax near '-'. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(Unknown Source) at Test.mssqldb(Test.java:80) at Test.main(Test.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)
Thanks,Gavin
View 3 Replies
View Related
Nov 20, 2006
This code used to work now I get an error(error follows code) can anyone tell me where I went wrong?[vbcode]i = 0 For i = 0 To 7 If requests(i) <> "" Then request = requests(i) Dim sql1 As String = "insert request_items ([req_id],[request]) Select Case max(req_id), " & request & " from(requests)" Dim myCommand1 As New SqlCommand(sql1, myConnection) myCommand1.ExecuteNonQuery() Else Continue For End If Next[/vbcode] Server Error in '/' 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 ','.
Source Error:
Line 73: Dim sql1 As String = "insert request_items ([req_id],[request]) Select Case max(req_id), " & request & " from(requests)"Line 74: Dim myCommand1 As New SqlCommand(sql1, myConnection)Line 75: myCommand1.ExecuteNonQuery()Line 76: ElseLine 77: Continue For
Source File: C:InetpubloansMemberPagesRequest.aspx.vb Line: 75
Stack Trace:
[SqlException (0x80131904): Incorrect syntax near ','.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857242 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734854 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.RunExecuteNonQueryTds(String methodName, Boolean async) +192 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +380 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 Request.Button1_Click(Object sender, EventArgs e) in C:InetpubloansMemberPagesRequest.aspx.vb:75 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.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) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
View 3 Replies
View Related
Apr 22, 2007
Hi all
My error is as follows: Incorrect syntax near '('.Line 27: acceptOrDeclineFriendship.UpdateParameters.Add("Response", answer)Line 28: acceptOrDeclineFriendship.UpdateParameters.Add("FriendID", friend_id)Line 29: acceptOrDeclineFriendship.Update()Line 30: Line 31: End Sub
Bear with me... I have a page where i use a repeater control to list users who have requested to be friends with the currently online user. The 'getFriendRequests' query looks like this:
SelectCommand="SELECT * FROM Friends, UserDetails WHERE (Friends.UserID = UserDetails.UserID) AND (FriendID = @UserID) AND (ApprovedByFriend = 'False') ORDER BY Friends.Requested DESC">This works.
Within each repeater template, there are 2 buttons, 'Accept' or 'Decline', like this: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="getFriendRequests">
<ItemTemplate>
(other stuff like avatar and username etc)
<asp:Button ID="accept" runat="server" Text="Accept" commandName="Accept" commandArgument='<%#Eval("UserID")%>' onCommand="Accept_Decline_Friends"/>
<asp:Button ID="decline" runat="server" Text="Decline" commandName="Decline" commandArgument='<%#Eval("UserID")%>' onCommand="Accept_Decline_Friends"/>
</ItemTemplate>
</asp:Repeater>
The code-behind (VB) which deals with this is as follows: Protected Sub Accept_Decline_Friends(ByVal sender As Object, ByVal e As CommandEventArgs)
'retrieve id of requestee and the answer accept/decline
Dim friend_id As String = e.CommandArgument.ToString
Dim answer As String = e.CommandName.ToString
'add the parameters
acceptOrDeclineFriendship.UpdateParameters.Add("Response", answer)
acceptOrDeclineFriendship.UpdateParameters.Add("FriendID", friend_id)
acceptOrDeclineFriendship.Update()
End Sub
Since the buttons are being created dynamically, this is how i track 1. the response from the currently logged in user 'Accept/Decline' and 2. who they are responding to (by their uniqueid)
This relates to a sqlDataSource on my .aspx page like this: <!---- update query when user has accepted the friendship ---->
<asp:SqlDataSource ID="acceptOrDeclineFriendship" runat="server" ConnectionString="<%$ xxx %>"
UpdateCommand="UPDATE Friends SET (ApprovedByFriend = @Response) WHERE (FriendID = @UserID) AND (UserID = @FriendID)">
<UpdateParameters>
<asp:ControlParameter Name="UserID" ControlID="userIdValue" />
</UpdateParameters>
</asp:SqlDataSource>
Which is meant to update my 'Friends' table to show that 'ApprovedByFriend' (the logged in user) is either 'Accept' or 'Decline', and record who's request was responded to.
I hope this is clear, just trying to suppy all of the information! The error appears to be saying that I have an issue with my code-behind, where i am telling the sqlDataSource above to UPDATE. What I can say is that for each button in the repeater, the 2 variables 'friend_id' and 'answer' are picking up the correct values.
Can anyone see any obvious problems here? Any help is very much appreciated as i am well and truley stuck!
View 1 Replies
View Related
Apr 7, 2008
I try to update from datalist by using sqlcommand, it throws an error on the date field:
Mark up:
10/11/2008 12:00:00 AM <--- the format in the SQL database
Error:
System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'DOB'.Dim strSQL As String = _
"UPDATE [Customers] SET [country] = @country, " & _"[nickName] = @nickname, [identityid] = @identityid " & _
"[DOB] = @DOB, [Hpno] = @Hpno " & _"[address] = @address, = @email " & _
"WHERE [CustomerID] = @CustomerID"
...Dim parameterdob As SqlParameter = _
New SqlParameter("@DOB", SqlDbType.DateTime)
parameterdob.Value = Request.Form("txtdob") & " 00:00:00"
myCommand.Parameters.Add(parameterdob)
myCommand.ExecuteNonQuery() <--- error here
...
<form id="form1" runat="server">
<asp:DataList ID="ProfileDataList" runat="server">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtdob" Text='<%#DataBinder.Eval(Container.DataItem, "DOB", "{0:d}")%>' />
</ItemTemplate>
</asp:DataList>
View 5 Replies
View Related
Sep 21, 2004
I'm stuck. This is in C#.
I am making the following query:
string query = INSERT INTO region_info(prefix, region, last_update) VALUES ('" + RegionInfo.Prefix + "', '" + region + "', ???TIMESTAMP???);
and then executing
query = query.Replace("???TIMESTAMP???", "'" + DateTime.Now.ToString("yyyyMMdd") + "'");
Thus, an example query is:
INSERT INTO region_info(prefix, region, last_update) VALUES ('907209', 'Alaska-Juneau', '20040921');
When I execute this query through my program(uses ADO.net), I get a "COUNT field incorrect or syntax error" exception, but if I run this same query through the query analyzer, it works fine.
Any ideas on what'z going wrong?
Thanks
View 5 Replies
View Related
May 27, 2014
Have been given this code to create a table
CREATE TABLE 'emaillist' (
'id' INT(11) NOT NULL AUTO_INCREMENT,
'clientname' VARCHAR(200) NOT NULL DEFAULT '0',
'email' VARCHAR(200) NOT NULL DEFAULT '0',
PRIMARY KEY ('id')
);
when I execute it says
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'emaillist'.
What the correct code should be?
View 3 Replies
View Related