Error Converting Data Type Nvarchar To Int
Contents |
here for a quick overview of the site Help Center Detailed answers to any error converting data type nvarchar to int stored procedure questions you might have Meta Discuss the workings and policies cannot convert nvarchar to int of this site About Us Learn more about Stack Overflow the company Business Learn more about convert nvarchar to int in stored procedure hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack
Error Converting Data Type Nvarchar To Int. Sql Server
Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error converting data type nvarchar to int up vote 0 down vote favorite I have a problem and i dont know where the problem lies.My visual studio throws an ssrs error converting data type nvarchar to int exception when i enter the details and click on the submit button on my REGISTER page.I dont know if the problem lies in my SQL query or my code.So i am posting both This is my Sql query: Create proc spRegisteredUsers @Name nvarchar(100), @UserName nvarchar(100), @Password nvarchar(200), @ContactNo int, @Email nvarchar(200) as Begin Declare @Count int Declare @ReturnCode int Select @Count = COUNT(UserName) from tblRegisteredUsers where UserName=@UserName if @Count>0 Begin Set @ReturnCode= -1 End Else Begin Set @ReturnCode= 1 Insert into tblRegisteredUsers values(@Name,@UserName,@Password,@ContactNo,@Email) End Select @ReturnCode as ReturnValue End whereas i get an exception on the line below: protected void btnRegSubmit_Click(object sender, EventArgs e) { if (Page.IsValid) { string CS = ConfigurationManager.ConnectionStrings["AK"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { SqlCommand cmd = new SqlCommand("spRegisteredUsers", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter Name = new SqlParameter("@Name", txtRegName.Text); SqlParameter UserName = new SqlParameter("@UserName", txtRegUsername.Text); SqlParameter Password = new SqlParameter("@Password", txtRegPassword.Text); SqlParameter ContactNo = new SqlParameter("@ContactNo", txtRegContact.Text); SqlParameter Ema
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow system data sqlclient sqlexception error converting data type nvarchar to int the company Business Learn more about hiring developers or posting ads with us Stack
Error Converting Data Type Nvarchar To Numeric. In Sql Server 2012
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of
Error Converting Data Type Nvarchar To Numeric. In Sql Server 2008
4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error converting datatype nvarchar to int up vote 5 down vote favorite I am getting the error Error http://stackoverflow.com/questions/21156204/error-converting-data-type-nvarchar-to-int converting datatype nvarchar to int Code: ALTER procedure [dbo].[sp_rcdoc] @regno int, @appname varchar(50), @DOI datetime, @COV varchar(50), @validtill date, @imgloc varchar(500), @ImagNo char(20), @Purposecode varchar(50), @FLAG varchar(3) AS BEGIN IF NOT EXISTS(SELECT regno FROM tblRCDocuments WHERE regno = @regno) BEGIN INSERT INTO tblRCDocuments(regno, appname, DOI, COV, validtill, imgloc, ImagNo, Purposecode, FLAG) VALUES(@regno, @appname, @DOI, @COV, @validtill, @imgloc, @ImagNo, @Purposecode, @FLAG) END sql sql-server database tsql share|improve this question edited Apr 24 at http://stackoverflow.com/questions/9953940/error-converting-datatype-nvarchar-to-int 9:03 Darren Davies 41.1k1469103 asked Mar 31 '12 at 7:26 chandu 35124 1 Please post the structure of tblRCDocuments –Chetter Hummin Mar 31 '12 at 7:28 1 you passing the parameter for regno is string datatype which reflect the error as you mention. Pass the int type value for regno. –Ghost Answer Mar 31 '12 at 7:30 1 OK, so just debug this - what values are you passing into the stored proc?? What if you call that INSERT statement manually, in SQL Server Mgmt Studio, with those parameters?? –marc_s Mar 31 '12 at 8:00 add a comment| 1 Answer 1 active oldest votes up vote 8 down vote Looks like regno is a nvarchar data type in your table and you have passed an int via your your procedure, either use a cast and convert @regno to an nvarchar or change the regno data type to an integer in the table. DECLARE @regnocast NVARCHAR(15) SET @regnocast = CAST(@regno AS NVARCHAR) Then in your SELECT, INSERT and WHERE clauses use @regnocast rather than @regno share|improve this answer edited Mar 31 '12 at 8:15 answered Mar 31 '12 at 7:59 Darren Davies 41.1k1469103 Thanks to every one for the help –chandu Mar 31 '12 at 8:46 1 Also: I wo
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article http://www.codeproject.com/Questions/714116/error-Converting-data-type-nvarchar-to-int-csharp or tip Post your Blog quick answersQ&A Ask a Question https://social.msdn.microsoft.com/Forums/sqlserver/en-US/18075b94-91c1-441f-bc31-e81f8f665029/error-converting-data-type-nvarchar-to-int?forum=transactsql View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C nvarchar to / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News error converting data The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ error: Converting data type nvarchar to int (c# code to sqlserver) Rate this: Please Sign up or sign in to vote. See more: C# public bool addMeeting(MeetingEntity meetingInfo) { List
(Русский)ישראל (עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語) HomeLibraryLearnDownloadsTroubleshootingCommunityForums Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: ERROR CONVERTING DATA TYPE NVARCHAR TO INT SQL Server > Transact-SQL Question 0 Sign in to vote
i m facing the Problem for this getting an error like this "ERROR CONVERTING DATA TYPE NVARCHAR TO INT" pls clear my error CREATE PROCEDURE [dbo] . [UserDepositDetails_SPIns] -- Add the parameters for the stored procedure here ( @regid int , @offer int , @deposit_amount varchar ( 16 ), @cashcardtype char ( 7 ), @deposittype char ( 6 ), @cheq_date DATE , @bankname varchar ( 30 ), @pFlag int out , @pMsg varchar ( 30 ) out ) AS BEGIN Declare --@ddate datetime, --@cdate varchar(10), @p int , @ptransname varchar ( 20 ), @myERROR int ; -- Local @@ERROR --@myRowCount int, -- Local @@ROWCOUNT set @p =( select MAX ( SandS_TUserRegform_pkID ) from SandS_TUserRegform1 ) --set @cdate=CONVERT(date,@cheq_date) select @ptransname = 'MyTransaction' BEGIN TRAN @pTransname --set @ddate=CURRENT_TIMES TAMP --set @cdate=@cheq_date Exec UserRegform_SPIns SandS_TUserRegform_FirstName , SandS_TUserRegform_SurName , SandS_TUserRegform_MartialStatus , SandS_TUserRegform_Gender , SandS_TUserRegform_DOB , SandS_TUserRegform_ContactNumber , SandS_TUserRegform_Occupation , pFlag , @pMsg , @regid ; --set @regid=@p set @p = @p + 1 set @p = @regid insert into SandS_TUserDepositDetails1 values ( @regid , @offer , @deposit_amount , @cashcardtype , @deposittype , @cheq_date , @bankname , CURRENT_TIMESTAMP ); COMMIT TRAN MyTransaction SELECT @myERROR = @@ERROR IF @myERROR != 0 GO TO HANDLE_ERROR SET @pFlag = 0 ; SET @pMsg = 'Success' ; RETURN 0 HANDLE_ERROR: BEGIN ROLLBACK TRAN SET @pMsg = @myERROR ; SET @pFlag = - 1 ; RETURN - 1 END ROLLBACK TRAN End GO ExecUserDepositDetails_SPIns , 7000 , '99000' , 'cash' , 'deposit' , '12-08-2010' , 'HDFC' , '' , '' Moved by Tom PhillipsModerator Tuesday, October 19, 2010 1:51 PM TSQL Question (From:SQL Server Database Engine) Tuesday, October 19, 2010 6:28 AM Reply | Quote Answers 0 Sign in to vote you need to run profiler and capture "Er