Update Error
Jan 30, 2008
hi ,
I TRY TO UPDATE THE DATA IN THE DATAGRID, IT THROWS THE ERROR LIKE Specified cast is not valid.
BELOW I ATTACHED, PLS GUIDE IS protected void updategrid_UpdateCommand(object source, DataGridCommandEventArgs e)
{
cmd.CommandText = "Update EMp_master set Empname=@Empname ,pwd=@pwd, emailId=@EmailId, Designation=@Designation,Type=@UserType,Reportsto=@reportsTo where empid=@id";
cmd.Parameters.Add("@Empname",SqlDbType.VarChar).Value = ((TextBox)e.Item.Cells[1].Controls[0]).Text;--- i got this error in this line
cmd.Parameters.Add("@pwd", SqlDbType.VarChar).Value = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
}
View 1 Replies
ADVERTISEMENT
Jan 24, 2007
I am trying to update a value in the aspnet_Users table using a gridview. I'm currently using the vw_aspnet_Users view to select which columns want to display. I have ensured the primary key exists and have it selected as a column to display (although it will serve no purpose). Unfortunately when I click on the advanced tab, it does not let me tick either boxes as they are both greyed out. I have followed "solutions" to this problem in other posts but as I definitely have the primary key source present AND selected, I dont see what the problem is. The only thing I have noticed is that in the "Configure the select statement" window, you are unable to see the aspnet_Users table in the dropdownlist (only the view is present). Non of the views that I choose allow me to update, however, when I choose one of my own tables that I have made (and these appear in the dropdownlist) the tickboxes become available.
Is there an underlying problem with editing SQL sources using views? I need a view as I need to display information found in aspnet_Users and aspnet_Membership
The following error is what is displayed after I click 'Update'
Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified
Thanks!
View 6 Replies
View Related
May 7, 2007
Hi,
I create the View which consist of multiple same table. When I want to update via the View, it doesn't allow me to update it, it gave out the following message,
View or function 'Table1' is not updatable because the modification affects multiple base tables.
View 1 Replies
View Related
Jul 25, 2007
how to update foreign key field where the primary field is in other database?
View 5 Replies
View Related
Jan 29, 2007
Hello,
I have a prject I am working on that uses a database connection to SQL Express 2005 to look up info of a person. The question I have is that I downloaded some code from a tutorial and it works fine but has some extra info that I dont want to use for example it saves FirstName, LastName, Title, Adress, Phone # in a table but I only want to use the Firstname, LastName and Phone# in the table but when I take these out of the Table with the wizard the Update Button I have has a error saying it is not parameterized and is missing Adress, Title am I missing something here? I can leave the Adress and Title in the table and just not have them on my Form and it works fine but I would like to get rid of the unwanted parameters from the table and have my Update Button work.
View 1 Replies
View Related
Oct 13, 2006
The clients are able to connect and pull data on existing accounts. However when users try to create a new version of an existing account or an actual new account, they get:
Db UpDate Error
ERROR 40002 01000: [Microsoft][ODBC SQL Server Driver][SQL Server]Command has been aborted.
Unable To Set Version Info. MODE: NEW
Class[APPOBJ.SerVersion]
Is this some type of version conflict? I've tried finding more information about the Error 40002 but I don't find the one specific to mine. I'm not an SQL expert but I would like to try and find out what the error message is trying to tell me. Any help would be greatly appreicated.
View 1 Replies
View Related
Jun 27, 2006
Why I am getting this error:
update failed because the following SET options have incorrect setting: 'ARITHABORT'
when trying to send this on the sql management express:
update rates set rates.ORIGIN = '800880011_ali' where rates.rate_plan_id = 3
View 1 Replies
View Related
Apr 10, 2007
Hello
I am trying to update a column containing URL's and include the "www." which had previously been omitted on many URL's in the column. But I get an error when trying to UPDATE
I have tried:
UPDATE table_nameSET URL = http://www.a2zdom.com/*WHERE URL = http://a2zdom.com/*
I have tried and left out the http: and also the /* but nothing works. Is this type of update not possible?
Thanks
View 7 Replies
View Related
Apr 27, 2007
Hi:I am trying to update a UserInfo record using a stored procedure. It uses a uniqueidentifier UserId as the primary key. I keep getting an error and am trying to trip it using try-catch statements in both SQL Server Express and VWD 2005.My challenge is that I cannot enter a sample UserId to test the query in SQL Server because it sees my unique identifier as a string and I cannot get the error back to VWD to see where the problem is. The stored procedure looks something like:ALTER PROCEDURE [dbo].[UpDateUserInfo] @Userid uniqueidentifier, @FirstName nvarchar(50), @LastName nvarchar(70), @WorkPhone nvarchar(50),ASBEGIN TRY SET NOCOUNT OFF; UPDATE Members SET FirstName = @FirstName, LastName = @LastName, WorkPhone = @WorkPhone, CellPhone = @CellPhone WHERE UserID = @Userid;END TRYBEGIN CATCH EXECUTE usp_GetErrorInfo;END CATCH; CREATE PROCEDURE [dbo].[usp_GetErrorInfo]AS SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_SEVERITY() AS ErrorSeverity, ERROR_STATE() AS ErrorState, ERROR_PROCEDURE() AS ErrorProcedure, ERROR_LINE() AS ErrorLine, ERROR_MESSAGE() AS ErrorMessage; When I put in the value d2dbf5-409d-4ef4-9d35-0a938f6ac608 which is an actual UserId in SQL server when I execute, the program tells me there incorrect syntax. So I would greatly appreciate it if somebody could help me with the following two questions: 1. How do I input a uniqueidentifier when executing a query in SQL Server Express?2. How can I get any errors that I trap (I think I have the right set up here) to show up back in my ASP.Net application? Any help greatly appreciate.Roger Swetnam
View 5 Replies
View Related
Jun 12, 2007
string cmdTxt = "Update penberry_SubjectName set SubjectLeaderId IN (
SELECT userid FROM aspnet_users WHERE username = @subjectLeaderName)
where SubjectCode = @subjectCode";
SqlConnection sqlconn = new SqlConnection(sqlConnStr);
SqlCommand sqlCmd = new SqlCommand(cmdTxt, sqlconn);
sqlCmd.Parameters.AddWithValue("@subjectLeaderName", subjectLeaderName);
sqlCmd.Parameters.AddWithValue("@subjectCode", subjectCode);
sqlconn.Open();
sqlCmd.ExecuteNonQuery(); hi guys i got this error from my program.Can anyone help me out?
View 9 Replies
View Related
Mar 21, 2006
hai..i cannot solve this sproblem...i need to update my databse after i edited the textfield.then system will return me 'UPDATE SUCCESS'(because i return value UPDATE SUCCESS).this seem like nothing wrong.but when i check the database,data did not update!!have anybody know that?
thanks!!my coding as below,
#Region "Edit student Then save"
Public Function editstudent(ByVal sIC As String, ByVal school As String, ByVal phone As String, ByVal pic As String, ByVal pwd As String, ByVal sname As String, ByVal gender As String, ByVal add As String, ByVal standard As String, ByVal osic As String) As String
' Create Instance of Connection and Command Object Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim command As String Dim mycommand As SqlCommand
command = "Update student_info set sic =@sic, Spassword =@pwd," & _ "sname =@sname, sphone=@phone,saddress=@add, sstandard=@standard,sschool=@school ,Sparent_IC=@pic ,sGender=@gender Where sic =@osic"
mycommand = New SqlCommand(command, myConnection) mycommand.CommandType = CommandType.Text
'' Add Parameters to Command Dim parameterIC As SqlParameter = New SqlParameter("@sic", SqlDbType.VarChar, 12) parameterIC .Value = sIC mycommand.Parameters.Add(parameterIC )
Dim parameteroIC As SqlParameter = New SqlParameter("@osic", SqlDbType.VarChar, 12) parameteroIC .Value = osic mycommand.Parameters.Add(parameteroIC )
Dim parameterpwd As SqlParameter = New SqlParameter("@pwd", SqlDbType.VarChar, 50) parameterpwd .Value = pwd mycommand.Parameters.Add(parameterpwd )
Dim parametername As SqlParameter = New SqlParameter("@sname", SqlDbType.VarChar, 100) parametername .Value = sname mycommand.Parameters.Add(parametername )
Dim parameteradd As SqlParameter = New SqlParameter("@add", SqlDbType.VarChar, 100) parameteradd .Value = add mycommand.Parameters.Add(parameteradd )
Dim parameterphone As SqlParameter = New SqlParameter("@phone", SqlDbType.VarChar, 12) parameterphone.Value = phone mycommand.Parameters.Add(parameterphone)
Dim parameterstandard As SqlParameter = New SqlParameter("@standard", SqlDbType.VarChar, 50) parameterstandard.Value = standard mycommand.Parameters.Add(parameterstandard)
Dim parametersschool As SqlParameter = New SqlParameter("@school", SqlDbType.VarChar, 100) parametersschool.Value = school mycommand.Parameters.Add(parametersschool)
Dim parameterpic As SqlParameter = New SqlParameter("@pic", SqlDbType.VarChar, 12) parameterpic.Value = pic mycommand.Parameters.Add(parameterpic)
Dim parametergender As SqlParameter = New SqlParameter("@gender", SqlDbType.VarChar, 1) parametergender.Value = gender mycommand.Parameters.Add(parametergender) Try
myConnection.Open() mycommand.ExecuteNonQuery() myConnection.Close() Return "Update Success !!!"
Catch exc As Exception
Return exc.ToString
End Try
End Function#End Region
End Class
View 2 Replies
View Related
Mar 30, 2006
Im getting this error when i try to change my value of my int RoleID: UPDATE statement conflicted with COLUMN FOREIGN KEY
constraint 'Roles_Users_FK1'. The conflict occurred in database
'lyngso', table 'Roles', column 'RoleID'.The statement has been terminated.
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:
UPDATE statement conflicted with COLUMN FOREIGN KEY constraint
'Roles_Users_FK1'. The conflict occurred in database 'lyngso', table
'Roles', column 'RoleID'.The statement has been terminated.
Source Error:
Line 373: tryLine 374: {Line 375: rowsAffected = dbCommand.ExecuteNonQuery();Line 376: }Line 377: finallyThe code that courses this error should be this code from my DatabaseHandler class:... queryString = "SELECT unitID FROM Units WHERE containerID = @containerID AND logDateTime = @logDateTime"; dbCommand = new SqlCommand(queryString, dbConnection); //ContainerID Param IDataParameter dbParam_containerID = new SqlParameter(); dbParam_containerID.ParameterName = "@containerID"; dbParam_containerID.Value = containerID; dbParam_containerID.DbType = System.Data.DbType.String; dbCommand.Parameters.Add(dbParam_containerID); //LogDateTime Param IDataParameter dbParam_logDateTime = new SqlParameter(); dbParam_logDateTime.ParameterName = "@logDateTime"; dbParam_logDateTime.Value = logDateTime; dbParam_logDateTime.DbType = System.Data.DbType.DateTime; dbCommand.Parameters.Add(dbParam_logDateTime);...The logDateTime param comes as a param to the method this code i located in. In my database the two tables are created as the following:CREATE TABLE [dbo].[Roles] ( [RoleID] [int] IDENTITY (1, 1) NOT NULL , [Name] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [RoleLevel] [int] NOT NULL ) CREATE TABLE [dbo].[Users] ( [UserID] [int] IDENTITY (1, 1) NOT NULL , [Firstname] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [Lastname] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [varchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Phone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [MobilPhone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [IsActive] [bit] NOT NULL , [RoleID] [int] NOT NULL ) To me it all looks fine, but my application doesn't agree with me....can anybody help here?
View 3 Replies
View Related
Mar 23, 2001
The trigger does set my CommAudit field to 1 when imaSlsCls is changed,
but at the end of the day when I issue the UPDATE command to set all CommAudit back to 0 I get an error. Is there a differant way to make it work?? See trigger, update command & error below.
Thanks for any help,
Tom
*** TRIGGER ***
CREATE TRIGGER [tblItemMaster_utr] ON dbo.tblItemMaster
FOR UPDATE
AS
IF (select imaSlsCls from inserted) <> (select imaSlsCls from deleted)
BEGIN
update tblItemMaster set commaudit = 1
from inserted, tblItemMaster
where inserted.imaitnbr = tblItemMaster.imaitnbr
END
*** UPDATE COMMAND ***
UPDATE tblItemMaster SET CommAudit = 0 WHERE CommAudit = 1
*** ERROR ***
Server: Msg 512, Level 16, State 1, Procedure tblItemMaster_utr, Line 5
Subquery returned more than 1 value. This is not permitted when the subquery
follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
View 2 Replies
View Related
Dec 5, 2000
hi, someone please tell me what's wrong with this update statement
It's supposed to get values for employee location from a test table, based on the first name and last name match, and update the outer table. I get this error...
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'a'.
update abs_employee a
set a.office_location =
(select b.Location
from abs_emptest b
where b.lastname = a.last_name and
b.firstname = a.first_name)
View 2 Replies
View Related
May 26, 2004
I am getting an error message when trying to run this update statement:
update table1
set col1 = (select substring(col2,1,2) + '-' + substring(col2,3,7) from table1)
Error message:
Server: Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
What am I doing wrong? Please help. Thanks.
View 5 Replies
View Related
May 10, 2007
Hi All,
I have a following update statement that returns an error:
update job_schedule_rep
set tlbkup = (select Right(Convert(VarChar(30), Convert(DateTime, Stuff(Stuf
f(Right(Replicate('0', 6) + Convert(VarChar(8), tl.active_start_time), 6), 3
,0, ':'), 6, 0, ':')), 100),7) as 'Transaction Log Backup'
from
(select name, job_id, active_start_time
from sysjobschedules
where name like 'TLBkup%') as tl
join
(select name, job_id
from sysjobs
where name like 'TL Backup%') as sjt
on sjt.job_id = tl.job_id
where sjt.name not like '%Maintenance%'
order by sjt.name)
Here is an error:
Server: Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery
follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
I have tried replacing '=' with in and exists but it didn't make any differe
nce.
How can I fix it?
Thanks.
View 5 Replies
View Related
Aug 13, 2004
HELP
I'm trying to add the new record to the database, but got the error from IE.
HTTP 500 - Internal server error
Internet Explorer
How can I add my info to my company SQL Sever 2000???
Following is my code:
<%
Dim sql
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:InetPubwwwrootdalyfpdbmarket.mdb"
sql="INSERT INTO Attendees (AttendeeFirstName,AttendeeLastName)"
sql=sql & " VALUES "
sql=sql & "('Saleng', 'Teng')"
objConn.Execute sql
objConn.close
%>
Thanks for your help.
scn@daly.com
View 1 Replies
View Related
Jan 29, 2004
Hi,
I have the following problem:
We replicate data from our mainframe (DMS II) to our SQLServer (and Informix) using Databridge and stored procedures.
We found that there was a problem with the Update stored procedure when it doesn an update of a row that doesn't exist. Instead of returning an error so that databridge can call the Insert stored procedure, it just says "0 rows updated".
We do not have the problem to Informix.
Do you have any idea how you can handle this?
Thanks for your help,
Jan
View 1 Replies
View Related
Jan 22, 2006
I am trying to set a particular field with the same value...I am using the following formula
update jokes
set author='Marym'
where jokes_id = 567 or 568
but i am receiving an error... I can do it using one joke_id but not when I try to implement it for 2 or more like above...
Any help for the syntax of the above query??
View 2 Replies
View Related
Jul 23, 2005
Hi all,I have just written a sql statement where I want two fields updatedfrom another table. The statement like so:update kpidmatterset clientcode,clientname = (select clientcode, clientnamefrom clientconversionwhere (clientcode = kpidmatter.clintcode))where exists(select clientcode, clientnamefrom clientconversionwhere (clientcode = kpidmatter.clintcode))This refuses to work.The statement I based this on worked (below) but only updated onefield (teach me for being too ambitions!). Can anyone see anythingobvious? I know that a DDL and sample data is far more useful but inthis case I think there's a simple syntax problem.I'd be most grateful if someone could spot my error.SamWorking sample:UPDATE kpidmatterSET clientpartner = (SELECT ContactNameFROM newnamesWHERE (feeearnercode = kpidmatter.clientpartnercode))where exists(SELECT ContactNameFROM newnamesWHERE (feeearnercode = kpidmatter.clientpartnercode))
View 6 Replies
View Related
Jul 23, 2005
Hi I'm trying to update a db based on the select statement which hasORDER BY in it.And due to that I'm getting error which states thatServer: Msg 1033, Level 15, State 1, Line 13The ORDER BY clause is invalid in views, inline functions, derivedtables, and subqueries, unless TOP is also specifiedHere is my sql statement:SELECT SUBSTRING(A.DESCR,1,10), B.SUPPORT_TEAM_MBR, EMPLID, COUNT(*)from PS_TEAM_CODE_TBL A, PS_TEAM_MEMBERS B, PS_MEMBER_PERSON CWHERE A.SUPPORT_TEAM_CD = B.SUPPORT_TEAM_CDAND A.EFF_STATUS = 'A'AND A.EFFDT >= (SELECT MAX(AX.EFFDT) FROM PS_TEAM_CODE_TBL AXWHERE A.SETID = AX.SETIDAND A.SUPPORT_TEAM_CD = AX.SUPPORT_TEAM_CD)AND B.SUPPORT_TEAM_MBR = C.SUPPORT_TEAM_MBRGROUP BY SUBSTRING(A.DESCR,1,10), B.SUPPORT_TEAM_MBR, EMPLIDHAVING COUNT(*) > 1ORDER BY SUBSTRING(A.DESCR,1,10)What should I do to avoid this problem.Thanks in advance for your help.
View 10 Replies
View Related
Feb 27, 2006
Hi,I am relatively new to SQL. I am using SQL 2000. I am trying toUpdate a field base in a criteria in a scond table.UPDATE Tbl1SET Tbl1.Row2 = '1'WHERE Tbl1.Row1 =(SELECT Tbl1.Row1FROM Tbl2, Tbl1WHERE Tbl2.Row1 = Tbl1.Row1 AND ({ fnCURRENT_TIMESTAMP () } >= Tbl2.Row3))Row 1 is the key between the two table. If I am doing only the selectbelow, I am getting the right value.SELECT Tbl1.Row1FROM Tbl2, Tbl1WHERE Tbl2.Row1 = Tbl1.Row1 AND ({ fnCURRENT_TIMESTAMP () } >= Tbl2.Row3)When I am running the entire querry, I am getting this error:Subquery returned more than 1 value. This is not permitted when thesubquery follows =, !=, <, <= , >, >= or when the subquery is used asan expression.The statement has been terminated.What I am trying to do is to update a field in Tbl1 base on a date inTbl2. If the date is expire, I want to raise a flag, in Tbl1.Thank youPhilippe
View 4 Replies
View Related
Jul 20, 2005
Hey all,i have a students_table which i want to do a multiple update on.Update student_tableset grant = 35000where course_id = 2There are lots of students in the student table which have course_id of2.I get this error:Subquery returned more than 1 value. This is not permitted when thesubquery follows =, !=, <, <= , >, >= or when the subquery is used as anexpression.The statement has been terminated.Does anyone know how to do a multiple update like this.It seems such asimple thing but im confused*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 1 Replies
View Related
Dec 7, 2006
I've implemented a UDF in SQL Server 2005 written in C#. The function with its assembly has been registered ok with SQL Server and works fine. It accepts three short strings (nvarchar of lengths 5, 35, and 35) and returns a SQL formatted string (SqlString).
When I run the function to test it it works just fine, and the same is true if I run the function inside a cursor to update a field in a table. But when I do a simple update it crashes. I've so far received two different errors: first one error saying a string could not be converted into an integer (but the error does not occur when I enter the same input values manually via a test Windows form, or through the new Query Analyzer as a single query - or using it inside a cursor). Then one error saying a string was too short (I couldn't use substring(X, Y) because the string, I was told, was too short - it wasn't).
The problem thus cannot be with the function since it works just fine if I do like this:
UPDATE myTable SET CodeField = dbo.fnMyFunction(Field1, Field2, Field3) WHERE PersonId = 10000001
And it works fine while doing the same thing inside a cursor (for instance working with the first 10, 100 or 1000 records).
But when I do this it crashes:
UPDATE myTable SET CodeField = dbo.fnMyFunction(Field1, Field2, Field3)
For your information the table has about 1.5M records (for testing, it contain more data when on the production server) and my aim is to update the CodeField column as quickly as possible. The CodeField is a 12-character string that is based on a rather complex algorithm including the Field1, Field2 and Field3 strings. I'm using C# because it manages strings much better than SQL Server - and it is so much easier coding this stuff.
Anyhow, I've had this kind of problem before with SQL Servers 2000 and 7 (maybe even 6.5) and it seems the problem occurs when I let SQL Server go about its business at its own pace. But when I do something to control that it really takes one record at a time (through using a cursor or executing the query with a WHERE clause like the one above) it works splendidly.
The problem here is that a cursor is way too slow, and there really shouldn't be a problem with a simple UPDATE command, should it? After all, everything works just fine except when I let SQL Server do what it does best (i.e. update the field at its own speed, whatever that is).
Any ideas? This is very frustrating since it is impossible to try and find the error - it isn't there when testing! And it is frustrating since I remember having had the same kind of problem (but every time with different errors arising) before without finding a solution (except for slowing everything down - not an option here).
Is there a certain tweak I can do to make things work out, or should I code things differently?
Thanks!
View 1 Replies
View Related
Feb 12, 2008
Code Snippetupdate dbo.tbl_prod_price
set dbo.tbl_prod_price.product_price = (SELECT ((dbo.tbl_product.product_price) + ((dbo.tbl_product.product_price)*.39)) FROM dbo.tbl_product
where dbo.tbl_product.product_id = dbo.tbl_prod_price.product_id and dbo.tbl_product.product_price is not null)
Where dbo.tbl_product.product_id in (select distinct dbo.tbl_prod_price.product_id from
dbo.tbl_prod_price)
This query is giving me following error:
The column prefix 'dbo.tbl_product' does not match with a table name or alias name used in the query.
Can anybody tell me where I am wrong???Please help.
Thanks,
View 4 Replies
View Related
Aug 6, 2006
Hello anyone know how to fix this error?
The data types ntext and nvarchar are incompatible in the equal to 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.SqlClient.SqlException: The data types ntext and nvarchar are incompatible in the equal to operator.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. Thanks , John
View 3 Replies
View Related
May 29, 2007
Hi, I have such a problem:I try to update (or insert) a row in my table and i fail althought i,ve read many posts here. I.ve created a button and "on_click" event to this button and want that event to update or insert a record in my table. I wrote: protected void selectButton_Click(object sender, EventArgs e) { String taskID = projectsGridView.SelectedRow.Cells[0].Text; usersSqlDataSource.UpdateCommand = "update [Users] set [TaskID]=@task where [UserID]=1"; usersSqlDataSource.UpdateParameters.Add("task", taskID); usersSqlDataSource.Update(); } The application creates error in the last line of code (usersSqlDataSource.Update();) and i receive such an error:You have specified that your update command compares all values on SqlDataSource 'usersSqlDataSource', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges. For me it looks like there is a problem while setting parameters. Shall i change some properties of the sqlDataSource or GridView? Please help..
View 2 Replies
View Related
Oct 26, 2007
I have a gridview and a dataset. When I start my application I see the results in my gridview. When I clic on edit and chanche some value and click on update it wil give me this error:ObjectDataSource 'ObjectDataSourcePersoon' could not find a non-generic method 'Update' that has parameters: naam, tussenvoegsel, achternaam, adres, woonplaats, telefoonnummer, original_id, Original_naam, Original_tussenvoegsel, Original_achternaam, Original_adres, Original_woonplaats, Original_telefoonnummer. Does someone know whats the problem??
View 10 Replies
View Related
Feb 27, 2008
hiii, i am using asp.net 2005 and sql server 2005...i hav a page in which i have used gridview and sql data source..i have written the update command for the same..the problem is when i add the where clause in the query i get an error ,,,,here is the code
UpdateCommand="UPDATE SMEtre_Master SET FirstName =@FirstName, LastName =@LastName, Type_of_SME =@Type_of_SME, Agency_Name =@Agency_Name, Email =@Email, Address =@Address, Phone =@Phone, Mobile =@Mobile, Fax =@Fax, Experience =@Experience, City =@City, State =@State where SME_Id=@SME_Id"
View 3 Replies
View Related
Mar 24, 2008
Hello all,
Iv been making a lot of progress on my first functional webapp, but I cannot get this bit of code to work correctly. I think my UPDATE SQL statement is where the problem is. It works fine the first time through when there is no Session("estimateid") set, but after that is set it gives me error this on line 40:
Incorrect syntax near '('.
1 Dim CustID As Integer
2
3 Dim DbConnection As SqlConnection
4 DbConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("harringtonairdb").ConnectionString)
5 DbConnection.Open()
6 Dim DbCommand As SqlCommand
7
8 If Session("estimateid") = 0 Then
9 Dim DbSqlInsert As String
10 DbSqlInsert = "INSERT INTO tblcustomers (strname, strAddress1, strAddress2, strCity, strState, strZip, strPhone, strEmail, strContact) VALUES (@name, @address1, @address2, @city, @state, @zip, @phone, @email, @contact)" & "SELECT @@IDENTITY AS CustID"
11 DbCommand = New SqlCommand(DbSqlInsert, DbConnection)
12 Else
13 Dim DbSqlUpdate As String
14 DbSqlUpdate = "UPDATE tblcustomers SET (strcustname=@name, straddress1=@address1, straddress2=@address2, strcity=@city, strstate=@state, strzip=@zip, strphone=@phone, stremail=@email, strcontact=@contact) JOIN tblestimates ON pkcustomerid WHERE pkestimateid=@estimateid"
15 DbCommand = New SqlCommand(DbSqlUpdate, DbConnection)
16 DbCommand.Parameters.AddWithValue("@estimateid", Session("estimateid"))
17
18 End If
19
20 DbCommand.Parameters.AddWithValue("@name", txtCustName.Text)
21 DbCommand.Parameters.AddWithValue("@address1", txtCustAddress1.Text)
22 DbCommand.Parameters.AddWithValue("@address2", txtCustAddress2.Text)
23 DbCommand.Parameters.AddWithValue("@city", txtCustCity.Text)
24 DbCommand.Parameters.AddWithValue("@state", txtCustState.Text)
25 DbCommand.Parameters.AddWithValue("@zip", txtCustZip.Text)
26 DbCommand.Parameters.AddWithValue("@phone", txtCustPhone.Text)
27 DbCommand.Parameters.AddWithValue("@email", txtCustEmail.Text)
28 DbCommand.Parameters.AddWithValue("@contact", txtCustTimes.Text)
29
30
31 If Session("estimateid") = 0 Then
32 CustID = Convert.ToInt32(DbCommand.ExecuteScalar())
33 DbCommand.Dispose()
34 Dim DbSqlInsert As String
35 DbSqlInsert = "INSERT INTO tblestimates (fkcustomerid) VALUES (@customerid)" & "SELECT @@IDENTITY AS EstimateID"
36 DbCommand = New SqlCommand(DbSqlInsert, DbConnection)
37 DbCommand.Parameters.AddWithValue("@customerid", CustID)
38 Session.Add("estimateid", Convert.ToInt32(DbCommand.ExecuteScalar()))
39 Else
40 DbCommand.ExecuteNonQuery()
41 End If
42
43 DbConnection.Close()
44 DbCommand.Dispose()
View 3 Replies
View Related
May 2, 2008
Hi forum, im converting some code and have an issue with th following code!!! many thanks for good advice, Paul
Line 55: SQLa = "UPDATE counted SET " & y & " = " & intClick & ", total = " & intTotal & " WHERE ID = " & RSpc.Fields("pc").ValueLine 56: Conn.Execute(SQLa)
System.Runtime.InteropServices.COMException: Syntax error in UPDATE statement.
Dim SQLa As String
View 8 Replies
View Related
Apr 7, 2004
I am trying to convert code I have working for access to work with SQL.
fldName, fldEmail, ID are the names in the database. recNum does have the value of the record that I want to edit. Here is the error I am getting.
System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '?'.
And here is the stack trace (which I don’t know how to read except for the line the error is on)
[SqlException: Line 1: Incorrect syntax near '?'.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +194
goodellweb.adm_contact.editNow_Click(Object sender, EventArgs e) in C:Inetpubwwwrootwebrootgoodellwebadmadm_contacts.aspx.vb:306
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1315
here is my code.
Dim editSQL As String = "Update tbEmail Set fldName=?, fldEmail=? Where ID=?"
Dim SqlConn As New SqlConnection(ConnStr)
Dim Cmd As New SqlCommand(editSQL, SqlConn)
Cmd.Parameters.Add(New SqlParameter("@fldName", nameEdit.Text))
Cmd.Parameters.Add(New SqlParameter("@fldEmail", emailEdit.Text))
Cmd.Parameters.Add(New SqlParameter("@recNum", recNum))
SqlConn.Open()
Try
Cmd.ExecuteNonQuery()
Finally
SqlConn.Close()
End Try
Response.Write("recNum " & recNum & " <br>")
Thanks
Michael
View 4 Replies
View Related
Apr 13, 2004
I have place a lblmessage.text = ex.Message to trace what happen and it show me a syntax error in update happen. I don't know whats wrong with my syntax. Can someone help me on this?
<%@ Page Language = "vb" Debug="true" %>
<%@ import namespace= "system.data" %>
<%@ import namespace= "system.data.oledb" %>
<script runat="server">
'set up connection
dim conn as new oledbconnection _
("provider = microsoft.jet.oledb.4.0;" & _
"data source = c:aspnetdataanking.mdb")
sub page_load(sender as object, e as eventargs)
if not page.ispostback then
filldatagrid()
end if
end sub
sub submit (sender as object, e as eventargs)
'insert new data
dim i,j as integer
dim params(7) as string
dim strtext as string
dim blngo as boolean = true
j = 0
for i = 0 to addpanel.controls.count -1
if addpanel.controls(i).gettype is _
gettype (textbox) then
strtext = ctype(addpanel.controls(i), _
textbox).text
if strtext <> "" then
params(j) = strtext
else
blngo = false
lblmessage.text = lblmessage.text & _
"you forgot to enter a value for " & _
addpanel.controls (i).id & "<p>"
lblmessage.style ("forecolor")= "red"
end if
j=j+1
end if
next
if not blngo then
exit sub
end if
dim strsql as string = "INSERT INTO tblusers " & _
"(firstname, lastname, address, city, state, " & _
"zip, phone) values (" & _
"'" & params(0) & "'," & _
"'" & params(1) & "'," & _
"'" & params(2) & "'," & _
"'" & params(3) & "'," & _
"'" & params(4) & "'," & _
"'" & params(5) & "'," & _
"'" & params(6) & "')"
executestatement(strsql)
filldatagrid()
end sub
sub dgdata_edit (sender as object, e as datagridcommandeventargs)
filldatagrid(e.item.itemindex)
end sub
sub dgdata_delete (sender as object, e as datagridcommandeventargs)
dim strsql as string = "DELETE FROM tblusers " & _
"WHERE userid = " & e.item.itemindex + 1
executestatement(strsql)
filldatagrid()
end sub
sub dgdata_update (sender as object, e as datagridcommandeventargs)
if updatedatastore(e) then
filldatagrid(-1)
end if
end sub
sub dgdata_cancel (sender as object, e as datagridcommandeventargs)
filldatagrid(-1)
end sub
sub dgdata_pageindexchanged (sender as object, e as datagridpagechangedeventargs)
dgdata.databind()
end sub
function updatedatastore (e as datagridcommandeventargs) as boolean
dim i,j as integer
dim params(7) as string
dim strtext as string
dim blngo as boolean = true
j = 0
for i =1 to e.item.cells.count - 3
strtext = ctype(e.item.cells(i).controls(0), _
textbox).text
if strtext <> "" then
params(j) = strtext
blngo = true
j= j+1
else
blngo = false
lblmessage.text = lblmessage.text & _
"you forgot to enter a value<p>"
end if
next
if not blngo then
return false
exit function
end if
dim strsql as string = "update tblusers SET " & _
"Firstname.value = '" & params(0) & "'," & _
"lastname.value = '" & params(1) & "'," & _
"address.value = '" & params(2) & "'," & _
"city.value = '" & params(3) & "'," & _
"state.value = '" & params(4) & "'," & _
"zip.value = '" & params(5) & "'," & _
"phone.value = '" & params(6) & "'," & _
" WHERE Userid = " & ctype(e.item.cells(0). _
controls(1), label).text
executestatement (strsql)
return blngo
end function
sub filldatagrid (optional editindex as integer = -1)
' open connection
dim objcmd as new oledbcommand _
("select * from tblusers", conn)
dim objreader as oledbdatareader
try
objcmd.connection.open ()
objreader = objcmd.executereader()
catch ex as exception
lblmessage.text = "error retrieving from the " & _
"database."
end try
dgdata.datasource = objreader
if not editindex.equals(nothing) then
dgdata.edititemindex = editindex
end if
dgdata.databind()
objreader.close
objcmd.connection.close()
end sub
function executestatement (strsql)
dim objcmd as new oledbcommand(strsql, conn)
try
objcmd.connection.open()
objcmd.executenonquery()
catch ex as exception
lblmessage.text = ex.message
end try
objcmd.connection.close()
end function
</script>
<html><body>
<asp:label id= "lblmessage" runat ="server" />
<form runat= "server">
<asp:datagrid id = "dgdata" runat ="server"
bordercolor = "black"
gridlines="vertical"
cellpadding ="4"
cellspacing="0"
width = "100%"
autogeneratecolumns = "False"
ondeletecommand = "dgdata_delete"
oneditcommand = "dgdata_edit"
oncancelcommand = "dgdata_cancel"
onupdatecommand = "dgdata_update"
onpageindexchanged= "dgdata_pageindexchanged"
font-names = "arial"
font-size="8pt"
showfooter = "true"
headerstyle-backcolor= "#cccc99"
footerstyle-backcolor= "#cccc99"
itemstyle-backcolor= "#ffffff"
alternatingitemstyle-backcolor="#cccccc">
<columns>
<asp:templatecolumn headertext="id">
<itemtemplate>
<asp:label id = "name" runat = "server"
text = '<%# container.dataitem("userid")%>' />
</itemtemplate>
</asp:templatecolumn>
<asp:boundcolumn headertext = "firstname"
datafield = "firstname" />
<asp:boundcolumn headertext = "lastname"
datafield = "lastname" />
<asp:boundcolumn headertext = "address"
datafield = "address" />
<asp:boundcolumn headertext = "city"
datafield = "city" />
<asp:boundcolumn headertext = "state"
datafield = "state" />
<asp:boundcolumn headertext ="zip"
datafield = "zip" />
<asp:boundcolumn headertext ="phone"
datafield = "phone" />
<asp:editcommandcolumn
edittext="Edit"
canceltext="cancel"
updatetext="update"
headertext = "edit"/>
<asp:buttoncolumn headertext = "delete?" text = "X"
commandname = "delete"
buttontype = "pushbutton" />
</columns>
</asp:datagrid><p>
<asp:panel id= "addpanel" runat = "server">
<table>
<tr>
<td width ="100" valign = "top">
first and last name:
</td>
<td width ="300" valign = "top">
<asp:textbox id= "tbfname" runat = "server"/>
<asp:textbox id= "tblname" runat = "server"/>
</td>
</tr>
<tr>
<td valign = "top">address:</td>
<td valign= "top">
<asp:textbox id= "tbaddress" runat = "server"/>
</td>
</tr>
<tr>
<td valign = "top">city, state, zip:</td>
<td valign= "top">
<asp:textbox id= "tbcity" runat = "server"/>
<asp:textbox id= "tbstate" runat = "server"/>
<asp:textbox id= "tbzip" runat = "server"
size=5 />
</td>
</tr>
<tr>
<td valign= "top">phone:</td>
<td valign= "top">
<asp:textbox id= "tbphone" runat = "server"
size = 11/><p>
</td>
</tr>
<tr>
<td colspan = "2" valign = "top" allign = "right">
<asp:button id = "btsubmit" runat ="server" text ="add"
onclick = "submit" />
</td>
</tr>
</table>
</asp:panel>
</form>
</body></html>
View 14 Replies
View Related