Ask a Question related to Macromedia Contribute General Discussion, Design and Development.

  1. #1

    Default Re: What is wrong?

    Take a look at your Stored Procedure. It takes a wide variety of data types.
    But in your code, you use an overloaded version of the Add() method of a
    SqlParameterCollection that takes 2 parameters. The second parameter of this
    method is of type "Object" because you need to pass the correct data type to
    the Stored Procedure in order to match the data type of the parameter in the
    Stored Procedure. However, you passed all strings in. What you need to do is
    cast each value to the correct data type when using this overloaded method.
    Example:

    cmd.Parameters.Add("@CopiesEC", CType(txtCopiesEC.Text, Int32))

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    [url]http://www.takempis.com[/url]
    Complex things are made up of
    lots of simple things.

    "Boris Bulit" <bulitb@bellsouth.net> wrote in message
    news:%23ud9ZmFXDHA.1640@TK2MSFTNGP10.phx.gbl...
    > I have the following code in vb.net but it doesn´t work:
    > When cmd.ExecuteNonQuery() run this error comes:
    > An unhandled exeption of type 'System.Data.SqlClient.SqlExeption occurred
    in
    > system.data.dll.
    > Aditional information: System error.
    >
    >
    > The code:
    >
    > Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles btnPrint.Click
    > Dim cn As New SqlConnection("integrated security=SSPI;data
    > source=(local);persist security info=False;initial
    catalog=Arte")SqlParaameter
    > Dim cmd As New SqlCommand
    > cmd.CommandText = "UpdateEditions"
    > cmd.CommandType = CommandType.StoredProcedure
    > cmd.Connection = cn
    > cmd.Parameters.Add("@Edition", txtEdition.Text)
    > cmd.Parameters.Add("@Color", cboColor.SelectedItem)
    > cmd.Parameters.Add("@EDate", cboDate.Value)
    > cmd.Parameters.Add("@CopiesEC", txtCopiesEC.Text)
    > cmd.Parameters.Add("@CopiesTB", txtCopiesTB.Text)
    > cmd.Parameters.Add("@PagesEC", txtCopiesEC.Text)
    > cmd.Parameters.Add("@PagesTB", txtCopiesTB.Text)
    > cn.Open()
    > cmd.ExecuteNonQuery()
    > cmd.Dispose()
    > cn.Close()
    > Me.Close()
    > End Sub
    >
    > and in sql server 2000 the followin Stored procedure:
    >
    > ALTER PROCEDURE UpdateEdition
    > @Edition as smallint,
    > @Color as char(10),
    > @EDate as datetime,
    > @CopiesEC as int,
    > @CopiesTB as int,
    > @PagesEC as smallint,
    > @PagesTB as smallint
    > AS
    > If Exists (Select * From Editions WHERE Edition = @Edition)
    > UPDATE Editions
    > SET Color=@Color, EDate=@EDate, CopiesEC=@CopiesEC, CopiesTB=@CopiesTB,
    > PagesEC=@PagesEC, PagesTB=@PagesTB
    > WHERE Edition = @Edition
    > ELSE
    > INSERT INTO Editions (Edition, Color, EDate, CopiesEC, CopiesTB, PagesEC,
    > PagesTB)
    > VALUES (@Edition ,@Color, @EDate, @CopiesEC, @CopiesTB, @PagesEC,
    @PagesTB)
    > RETURN
    >
    >
    >

    Kevin Spencer Guest

  2. Similar Questions and Discussions

    1. something wrong..
      I want to integrate following php-file into my Flash-movie, but something still does not work. The Php-file is like that: Online it looks like...
    2. What am I doing wrong?
      > rs.Source="SELECT id From User Where upper I asked this before... Try sql = "SELECT id FROM user WHERE UPPER(cLoginID) = '" & vUserID &...
    3. What am I doing wrong???!?!
      I have a simple form that based on the the two inputs, ExAD_Tracking and ExAD_DateEntered, will query the database and display the records...
    4. What am I doing wrong
      I am trying to fade in an image over time, however the image keeps blinking, it fades in all the time. Below is my script. on exitFrame me go to...
    5. What am I doing wrong with this SP??
      Gives me a NULL value at this line. and I know it has a 1 myShippingDetails.theShippingType = CStr(parametertheShippingType.Value) Public...
  3. #2

    Default Re: What is wrong?

    In addition your code

    cmd.CommandText = "UpdateEditions" << remove the 's' at the end

    ALTER PROCEDURE UpdateEdition

    you have UpdateEditions and not UpdateEdition

    Missing the 's' or with extra 's'


    "Boris Bulit" <bulitb@bellsouth.net> wrote in message
    news:%23ud9ZmFXDHA.1640@TK2MSFTNGP10.phx.gbl...
    > I have the following code in vb.net but it doesn´t work:
    > When cmd.ExecuteNonQuery() run this error comes:
    > An unhandled exeption of type 'System.Data.SqlClient.SqlExeption occurred
    in
    > system.data.dll.
    > Aditional information: System error.
    >
    >
    > The code:
    >
    > Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles btnPrint.Click
    > Dim cn As New SqlConnection("integrated security=SSPI;data
    > source=(local);persist security info=False;initial catalog=Arte")
    > Dim cmd As New SqlCommand
    > cmd.CommandText = "UpdateEditions"
    > cmd.CommandType = CommandType.StoredProcedure
    > cmd.Connection = cn
    > cmd.Parameters.Add("@Edition", txtEdition.Text)
    > cmd.Parameters.Add("@Color", cboColor.SelectedItem)
    > cmd.Parameters.Add("@EDate", cboDate.Value)
    > cmd.Parameters.Add("@CopiesEC", txtCopiesEC.Text)
    > cmd.Parameters.Add("@CopiesTB", txtCopiesTB.Text)
    > cmd.Parameters.Add("@PagesEC", txtCopiesEC.Text)
    > cmd.Parameters.Add("@PagesTB", txtCopiesTB.Text)
    > cn.Open()
    > cmd.ExecuteNonQuery()
    > cmd.Dispose()
    > cn.Close()
    > Me.Close()
    > End Sub
    >
    > and in sql server 2000 the followin Stored procedure:
    >
    > ALTER PROCEDURE UpdateEdition
    > @Edition as smallint,
    > @Color as char(10),
    > @EDate as datetime,
    > @CopiesEC as int,
    > @CopiesTB as int,
    > @PagesEC as smallint,
    > @PagesTB as smallint
    > AS
    > If Exists (Select * From Editions WHERE Edition = @Edition)
    > UPDATE Editions
    > SET Color=@Color, EDate=@EDate, CopiesEC=@CopiesEC, CopiesTB=@CopiesTB,
    > PagesEC=@PagesEC, PagesTB=@PagesTB
    > WHERE Edition = @Edition
    > ELSE
    > INSERT INTO Editions (Edition, Color, EDate, CopiesEC, CopiesTB, PagesEC,
    > PagesTB)
    > VALUES (@Edition ,@Color, @EDate, @CopiesEC, @CopiesTB, @PagesEC,
    @PagesTB)
    > RETURN
    >
    >
    >

    MS News \(MS LVP\) Guest

  4. #3

    Default What is wrong?

    When I try to add text, its just not doing anything, i put the text tool, then i type, ive tried changing the size and colour, whats wrong?
    Jamie Orr Guest

  5. #4

    Default Re: What is wrong?

    Jamie, sounds like you are working with a bitmap image. Go to toolbar>image>mode>change to RGB.
    Jodi Frye Guest

  6. #5

    Default Re: What is wrong?

    oops, scratch that...text can be added to a bitmap. So other guesses would be your preferences need to be deleted > hold down alt+ctrl+shift key immediatedly after clicking desktop icon to open elements...note pops up asking if you want to delete prefs say 'OK'. Another thing is that you are adding text to a hidden layer...if you have more than one layer.
    Jodi Frye Guest

  7. #6

    Default What is wrong?

    Can anyone spot an error in this query??!!

    <CFQUERY NAME="GetEvents" DATASOURCE="#application.datasource#">
    SELECT
    EventCategory.EventCategory,EventPrivate,EVENT.Eve ntCatID,EventDate,EventDateEnd
    ,EventNoTime,EventDescr,EventID,EventName,EventDat e
    FROM EVENT left join EventCategory on EVENT.EventCatID =
    EventCategory.EventCatID
    WHERE EVENT.Inactive = 0 AND EventPrivate = 0 AND
    <cfif session.userid is "">
    Event.TaskID = 0 and
    <cfelse>
    <cfif session.userTasks neq 0> (Event.TaskID IN (#session.userTasks#) or
    (Event.TaskID = 0 )) and </cfif>
    <cfif session.SrchTaskid neq 0> Event.TaskID = #session.SrchTaskid# and
    </cfif>
    </cfif>
    {fn MONTH(EventDate)}={fn MONTH(#ThisDate#)} AND
    {fn YEAR(EventDate)}={fn YEAR(#ThisDate#)}
    <cfif CatIDs neq 0>
    AND EVENT.EventCatID in (#PreserveSingleQuotes(CatIDs)#)
    </cfif>
    <cfif trim(session.usercats neq "")>
    UNION
    SELECT
    EventCategory.EventCategory,EventPrivate,EVENT.Eve ntCatID,EventDate,EventDateEnd
    ,EventNoTime,EventDescr,EventID,EventName,EventDat e
    FROM EVENT LEFT JOIN EventCategory on EVENT.EventCatID =
    EventCategory.EventCatID
    WHERE EVENT.Inactive = 0 AND EventPrivate = 1 AND
    <cfif session.userid is "">
    Event.TaskID = 0 and
    <cfelse>
    <cfif session.userTasks neq 0> ( Event.TaskID IN (#session.userTasks#) or
    Event.TaskID = 0) and </cfif>
    <cfif session.SrchTaskid neq 0> (Event.TaskID = #session.SrchTaskid#) and
    </cfif>
    </cfif>
    {fn MONTH(EventDate)}={fn MONTH(#ThisDate#)} AND
    {fn YEAR(EventDate)}={fn YEAR(#ThisDate#)}
    <cfif session.usercats neq 0>
    AND EVENT.EventCatID in (#PreserveSingleQuotes(session.usercats)#)
    </cfif>
    </cfif>
    </CFQUERY>

    Niles Runeberg Guest

  8. #7

    Default Re: What is wrong?

    What database are you using?
    are Month() or Year() valid functions in your database?
    What's the error that's getting thrown? that usually helps when trying to help
    troubleshoot something...

    {fn MONTH(EventDate)}={fn MONTH(#ThisDate#)} AND
    {fn YEAR(EventDate)}={fn YEAR(#ThisDate#)}


    Kronin555 Guest

  9. #8

    Default Re: What is wrong?

    Oops... very true.

    I am getting this error:

    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
    Access Driver] Syntax error (missing operator) in query expression
    'EVENT.Inactive = 0 AND EventPrivate = 0 AND (Event.TaskID IN () or
    (Event.TaskID = 0 )) and month(EventDate)=month(#11/10/2005 12:11:41#) AND
    Year(EventDate)=Year(#11/10/2005 12:11:41#)'.

    I am using Microsoft Access and CF MX 6.1

    Thanks ;)

    Niles Runeberg Guest

  10. #9

    Default Re: What is wrong?

    is month() a function in Access? is year()? if not, that's your problem.

    I don't use access, personally, so I can't tell you one way or another whether
    those functions are valid. I know in PostgreSQL they aren't.

    Kronin555 Guest

  11. #10

    Default Re: What is wrong?

    hmmm...

    I was thinking that...

    What would be a suitable replacement?
    Niles Runeberg Guest

  12. #11

    Default Re: What is wrong?

    {fn MONTH(EventDate)}={fn MONTH(#ThisDate#)} AND

    to_char(eventdate,'mm') = #month(thisdate)#

    This works in Postgresql. Not sure about Access...
    Kronin555 Guest

  13. #12

    Default Re: What is wrong?

    Wouldn't they both have to be to_char?


    Niles Runeberg Guest

  14. #13

    Default Re: What is wrong?

    no, because one is a coldfusion variable (thisdate) and the other one is a
    database field (eventdate)

    You use a database function on the database field (to_char(eventdate,'mm'))
    that converts it to a numeric value between 01 and 12 that represents the month.

    You use a coldfusion function on the coldfusion variable (#month(thisdate)#)
    that converts it to a numeric value between 1 and 12 that represents the month.

    So what you end up sending to the database is this (after Coldfusion has
    processed its stuff):

    to_char(eventdate,'mm') = 2

    And the database, with the to_char function, pulls the month value out of
    eventdate, and you end up with something like this:

    3 = 2 (assuming the month in eventdate is march, and the month in thisdate is
    february)

    Kronin555 Guest

  15. #14

    Default Re: What is wrong?

    MONTH() and YEAR() are a valid function in Access, but you don't need all of
    the {fn... garbage, just call the function in the query. Try it without it.

    SELECT
    EventCategory.EventCategory,EventPrivate,EVENT.Eve ntCatID,EventDate,EventDateEnd
    ,EventNoTime,EventDescr,EventID,EventName,EventDat e
    FROM EVENT left join EventCategory on EVENT.EventCatID =
    EventCategory.EventCatID
    WHERE EVENT.Inactive = 0 AND EventPrivate = 0 AND
    <cfif session.userid is "">
    Event.TaskID = 0 and
    <cfelse>
    <cfif session.userTasks neq 0> (Event.TaskID IN (#session.userTasks#) or
    (Event.TaskID = 0 )) and </cfif>
    <cfif session.SrchTaskid neq 0> Event.TaskID = #session.SrchTaskid# and </cfif>
    </cfif>
    MONTH(EventDate)=MONTH(#ThisDate#) AND
    YEAR(EventDate)=YEAR(#ThisDate#)
    <cfif CatIDs neq 0>
    AND EVENT.EventCatID in (#PreserveSingleQuotes(CatIDs)#)
    </cfif>
    <cfif trim(session.usercats neq "")>
    UNION
    SELECT
    EventCategory.EventCategory,EventPrivate,EVENT.Eve ntCatID,EventDate,EventDateEnd
    ,EventNoTime,EventDescr,EventID,EventName,EventDat e
    FROM EVENT LEFT JOIN EventCategory on EVENT.EventCatID =
    EventCategory.EventCatID
    WHERE EVENT.Inactive = 0 AND EventPrivate = 1 AND
    <cfif session.userid is "">
    Event.TaskID = 0 and
    <cfelse>
    <cfif session.userTasks neq 0> ( Event.TaskID IN (#session.userTasks#) or
    Event.TaskID = 0) and </cfif>
    <cfif session.SrchTaskid neq 0> (Event.TaskID = #session.SrchTaskid#) and
    </cfif>
    </cfif>
    MONTH(EventDate)=MONTH(#ThisDate#)} AND
    YEAR(EventDate)=YEAR(#ThisDate#)
    <cfif session.usercats neq 0>
    AND EVENT.EventCatID in (#PreserveSingleQuotes(session.usercats)#)
    </cfif>
    </cfif>
    </CFQUERY>

    Phil

    paross1 Guest

  16. #15

    Default Re: What is wrong?

    There was an arrant } left over, and even after deleting that I still got the same error message.

    hmmm...
    Niles Runeberg Guest

  17. #16

    Default Re: What is wrong?

    Maybe something more like this....

    MONTH(EventDate) = #MONTH(ThisDate)# AND
    YEAR(EventDate) = #YEAR(ThisDate)#

    --or--

    MONTH(EventDate) =' #MONTH(ThisDate)#' AND
    YEAR(EventDate) = '#YEAR(ThisDate)#'

    Phil

    paross1 Guest

  18. #17

    Default Re: What is wrong?

    I am not so sure it is the date lines...

    I commented portions of the code out and I no longer get the error...

    <CFQUERY NAME="GetEvents" DATASOURCE="#application.datasource#">
    SELECT
    EventCategory.EventCategory,EventPrivate,EVENT.Eve ntCatID,EventDate,EventDateEnd
    ,EventNoTime,EventDescr,EventID,EventName,EventDat e
    FROM EVENT LEFT JOIN EventCategory ON EVENT.EventCatID =
    EventCategory.EventCatID
    WHERE EVENT.Inactive = 0 AND EventPrivate = 0 AND
    <!---<cfif session.userid is "">
    Event.TaskID = 0 AND
    <cfelse>
    <cfif session.userTasks neq 0>
    (Event.TaskID IN (#session.userTasks#) OR (Event.TaskID = 0 )) AND
    </cfif>
    <cfif session.SrchTaskid neq 0>
    Event.TaskID = #session.SrchTaskid# AND
    </cfif>
    </cfif>--->
    MONTH(EventDate) = MONTH(#ThisDate#) AND
    YEAR(EventDate) = YEAR(#ThisDate#)
    <!---<cfif CatIDs neq 0>
    AND EVENT.EventCatID in (#PreserveSingleQuotes(CatIDs)#)
    </cfif> --->

    <cfif trim(session.usercats neq "")>
    UNION
    SELECT
    EventCategory.EventCategory,EventPrivate,EVENT.Eve ntCatID,EventDate,EventDateEnd
    ,EventNoTime,EventDescr,EventID,EventName,EventDat e
    FROM EVENT LEFT JOIN EventCategory ON EVENT.EventCatID =
    EventCategory.EventCatID
    WHERE EVENT.Inactive = 0 AND EventPrivate = 1 AND
    <!---<cfif session.userid is "">
    Event.TaskID = 0 AND
    <cfelse>
    <cfif session.userTasks neq 0> (Event.TaskID IN (#session.userTasks#) OR
    Event.TaskID = 0) AND </cfif>
    <cfif session.SrchTaskid neq 0> (Event.TaskID = #session.SrchTaskid#) AND
    </cfif>
    </cfif> --->
    MONTH(EventDate) = MONTH(#ThisDate#) AND
    YEAR(EventDate) = YEAR(#ThisDate#)
    <!---<cfif session.usercats neq 0>
    AND EVENT.EventCatID in (#PreserveSingleQuotes(session.usercats)#)
    </cfif>--->
    </cfif>
    </CFQUERY>

    I wonder if maybe my CFIF statements are not working properly...

    Odd...


    Niles Runeberg Guest

  19. #18

    Default Re: What is wrong?

    What is the data type of some of the database fields within the <CFIF> tags?
    For instance, if Event.TaskID is actually character/char/varchar, etc., you
    will need to use single quotes around the value that you are comparing to the
    field in your query. Failure to do so will generate the error that you are
    seeing.

    Phil

    paross1 Guest

  20. #19

    Default Re: What is wrong?

    It is something in the commented code... I just have no idea what :(

    <CFQUERY NAME="GetEvents" DATASOURCE="#application.datasource#">
    SELECT
    EventCategory.EventCategory,EventPrivate,EVENT.Eve ntCatID,EventDate,EventDateEnd
    ,EventNoTime,EventDescr,EventID,EventName,EventDat e
    FROM EVENT LEFT JOIN EventCategory ON EVENT.EventCatID =
    EventCategory.EventCatID
    WHERE EVENT.Inactive = 0 AND EventPrivate = 0 AND
    <!---<cfif session.userid is "">
    Event.TaskID = 0 AND
    <cfelse>
    <cfif session.userTasks neq 0>
    (Event.TaskID IN (#session.userTasks#) OR (Event.TaskID = 0 )) AND
    </cfif>
    <cfif session.SrchTaskid neq 0>
    Event.TaskID = #session.SrchTaskid# AND
    </cfif>
    </cfif>--->
    MONTH(EventDate) = MONTH(#ThisDate#) AND
    YEAR(EventDate) = YEAR(#ThisDate#)
    <cfif CatIDs neq 0>
    AND EVENT.EventCatID in (#PreserveSingleQuotes(CatIDs)#)
    </cfif>

    <cfif trim(session.usercats neq "")>
    UNION
    SELECT
    EventCategory.EventCategory,EventPrivate,EVENT.Eve ntCatID,EventDate,EventDateEnd
    ,EventNoTime,EventDescr,EventID,EventName,EventDat e
    FROM EVENT LEFT JOIN EventCategory ON EVENT.EventCatID =
    EventCategory.EventCatID
    WHERE EVENT.Inactive = 0 AND EventPrivate = 1 AND
    <!---<cfif session.userid is "">
    Event.TaskID = 0 AND
    <cfelse>
    <cfif session.userTasks neq 0>
    (Event.TaskID IN (#session.userTasks#) OR Event.TaskID = 0) AND
    </cfif>
    <cfif session.SrchTaskid neq 0>
    (Event.TaskID = #session.SrchTaskid#) AND
    </cfif>
    </cfif> --->
    MONTH(EventDate) = MONTH(#ThisDate#) AND
    YEAR(EventDate) = YEAR(#ThisDate#)
    <cfif session.usercats neq 0>
    AND EVENT.EventCatID in (#PreserveSingleQuotes(session.usercats)#)
    </cfif>
    </cfif>
    </CFQUERY>

    Niles Runeberg Guest

  21. #20

    Default Re: What is wrong?

    What is SESSION.userTasks? is it a comma-delimited list?

    If so, do this:
    <cfif listlen(session.userTasks) gt 0>Event.TaskID IN (#session.userTasks#,0) and </cfif>
    Kronin555 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139