Hi guys need some help, someone has given me some code to help me filter a gridview by the surname field by the selected letter of a dropdown list. My code is below, however if i select a letter from the dropdown and click the button i get an error, can someone take a look please. <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<script runat="server"> Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim dset As New Data.DataSet Dim dview As New Data.DataView dview.Table = dset.Tables("modelRegistration1") dview.RowFilter = "surname LIKE" + surnameFilter.SelectedValue.ToString() + " % " GridView1.DataSource = dview GridView1.DataBind() End Sub </script>
error message is Server Error in '/KayKay' Application.
Syntax error: Missing operand after 'LIKEC' operator. 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.SyntaxErrorException: Syntax error: Missing operand after 'LIKEC' operator.Source Error:
Line 6: Dim dview As New Data.DataView Line 7: dview.Table = dset.Tables("modelRegistration1") Line 8: dview.RowFilter = "surname LIKE" + surnameFilter.SelectedValue.ToString() + " % " Line 9: GridView1.DataSource = dview Line 10: GridView1.DataBind()Source File: E:InetpubwwwrootKayKayAdminupdateModels.aspx Line: 8 Stack Trace:
I have a stored procedure that works fine on SQL Server 2000 or 2005,but when run on an machine running MSDE, I get the Operand type clash,int is incompatible with text data type error. The data type isactually text and text is the type of data being passed. Anyparameters not being used are defaulted to null. Any ideas why thiswould happen on MSDE and work fine anywhere else?Thanks so much.
I'm getting this error when trying to insert data into a table.
"Operand type clash: int is incompatible with date"
This is the SQL I used to create the table:
Code: CREATE TABLE customers( customer_id int IDENTITY(1,1) NOT NULL, member_yn char(1) NOT NULL, membership_number int NOT NULL, date_became_member date NOT NULL,
[Code]....
This is the SQL I am using to add data: (Note that there are two dates in each line, scroll to the side.)
Code: INSERT INTO customers VALUES ('y', 156, 2010-08-29, 'John', 'Smith', '1235 Main Street, Dunmore, PA 18512', 6963287654, 'jsmith@hotmail.com', 1986-06-23); INSERT INTO customers VALUES ('y', 159, 04/15/2011, 'Mary', 'Jones', '235 Ardmore Blvd, Pittsburgh, PA 15221', 3429831594, 'jones_mary@gmail.com', 01/12/1992);
Each of the lines above to add data uses a different data format because I tried both, while commenting out the other, hoping for the problem to go away with the change in format.
Here is the SQL code to create a primary key for this table:
Code: ALTER TABLE customers ADD CONSTRAINT pk_customers PRIMARY KEY (customer_id);
Im trying to insert a new record into tblMessages...the unique ID generated for MessageID is the value I want to use as a value for the MessageID field when inserting a new record in tblUsersAndMessagesI have the following sp: -- ================================================ -- Template generated from Template Explorer using: -- Create Procedure (New Menu).SQL -- -- Use the Specify Values for Template Parameters -- command (Ctrl-Shift-M) to fill in the parameter -- values below. -- -- This block of comments will not be included in -- the definition of the procedure. -- ================================================ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE spNewMessage @UserIDSender nvarchar(256), @MessageTitle nvarchar(50), @MessageContent text, @MessageType int, @MessageID uniqueidentifier, @UserID uniqueidentifier AS Begin Set NoCount on DECLARE @WhateverID uniqueidentifier INSERT INTO tblMessages(UserIDSender,MessageTitle,MessageContent,MessageType) VALUES (@UserIDSender,@MessageTitle,@MessageContent,@MessageType) Select @WhateverID=@@Identity INSERT INTO tblUsersAndMessages(MessageID,UserID) VALUES (@WhateverID,@UserID) End GO And here are my tables:tblUsersAndMessages allow nullsMessageID uniqueidentifier falseUserID uniqueidentifier falseNew bit false *default set to ((1)) tblMessages allow nullsMessageID uniqueidentifier false *PK default set to (newid())UserIDSender uniqueidentifier falseMessageTitle nvarchar(50) trueMessageContent text trueSentDateTime datetime false * default set to (getdate())MessageType int false Now when I try to add my SP I get this error:Msg 206, Level 16, State 2, Procedure spNewMessage, Line 22Operand type clash: numeric is incompatible with uniqueidentifierWhat can this be?!?
I uploading an image from a web page into Sql Server 2000 database. I call a stored procedure with the parameter @Flag of type Image. When I tried to pass a null value to this parameter I got the error:"Operand type clash: nvarchar is incompatible with image".I was adding the parameter like this:sqlCmd.Parameters.AddWithValue("@Flag", DBNull.Value);After trying few different things I found a workaround using the following:sqlCmd.Parameters.Add("@Flag", SqlDbType.Image);sqlCmd.Parameters["@Flag"].Value = DBNull.Value;Possibly a bug in the SqlCommand.Parameters.AddWithValue method ?
SELECT TOP 1000 *... case when Rownum<= datediff(day, salesdate, baseenddate) then DATEADD(mm, RowNum, salesdate) /*error at this point*/ else 0 end as subscriptionrowdate FROM Subsrow
Rownum is an integer type. DATEADD is the part when the error is but i dont know how to convert this to int
Hi all I am trying to convert the string "(null)" in the [PASSWORD] column of my table to an actual NULL value. I have tried to use two different forms of a conditional operator to achieve this end. However I am getting the below errors both can be summed up with the following statement.
DT_STR operand cannot be used with the conditional operation. The expression directly below however is using a type DT_I4 in the conditional clause as this is what FINDSTRING returns. Hence the equivalencey test to the literal integer 0. So I must say I am somewhat confused by this. Does anyone know why neither of the below statements are working?
Also is there an easy way to accomplish what I am trying to do - convert the string "(null)" in the [PASSWORD] column of my table to an actual NULL value?
Error at Administrator Data Flow Task [Derived Column [1985]]: For operands of the conditional operator, the data type DT_STR is supported only for input columns and cast operations. The expression "FINDSTRING(PASSWORD,"(null)",1) == 0 ? PASSWORD : NULL(DT_STR,255,1252)" has a DT_STR operand that is not an input column or the result of a cast, and cannot be used with the conditional operation. To perform this operation, the operand needs to be explicitly cast with a cast operator.
Error at Administrator Data Flow Task [Derived Column [1985]]: For operands of the conditional operator, the data type DT_STR is supported only for input columns and cast operations. The expression "LOWER(TRIM(PASSWORD)) != "(null)" ? PASSWORD : NULL(DT_STR,255,1252)" has a DT_STR operand that is not an input column or the result of a cast, and cannot be used with the conditional operation. To perform this operation, the operand needs to be explicitly cast with a cast operator.