February 11, 2017 at 7:50 am
From asp.net project I need to insert data into one table in SQL server which has a lot of data type as below.
What is perfect way to declare variable data type in asp.net to match SQL data type?
(I only use string, integer before)
[AUTHNO] [dbo].[vcType] NOT NULL,[SEQUENCE] [dbo].[sNumber] NOT NULL,
[NOTES] [varchar](max) NULL,
[SUBJECT] [dbo].[vcAddress] NULL,
[SECURED_YN] [dbo].[sNumber] NULL,
[CREATEBY] [dbo].[iNumber] NULL,
[CREATEDATE] [datetime] NOT NULL
February 11, 2017 at 1:33 pm
IMHO, call a stored procedure.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 11, 2017 at 1:53 pm
Yes, I'll call store procedure.
But, first I need declare variable in asp.net, assign value to variable from various controls, such as text boxes, drop down lists.
After that, will pass values to store procedure.
February 11, 2017 at 5:11 pm
I don't know enough about asp.net to tell you off the top of my head but the following search seems useful.
https://www.google.com/?gws_rd=ssl#q=match+asp.net+variables+to+sql+server+data+types
--Jeff Moden
Change is inevitable... Change for the better is not.
February 12, 2017 at 7:57 am
Jeff Moden - Saturday, February 11, 2017 5:11 PMI don't know enough about asp.net to tell you off the top of my head but the following search seems useful.
https://www.google.com/?gws_rd=ssl#q=match+asp.net+variables+to+sql+server+data+types
You build your SQL EXECUTE statement from the values in your controls, being sure to do your client-side validation first. Then you fire the statement. No matter how you declared your .NET variables, the procedure will receive the values in the data types it expects. For example, if you have a string variable in .NET that you pass as a datetime parameter, SQL will receive it as a datetime. If the string passed isn't a valid datetime value, the call to the procedure will fail on the .NET side.
February 12, 2017 at 10:33 am
Understood but if you don't know that you shouldn't pass a "DOUBLE Word" to a "TinyInt", you're in deep Kimchi. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
February 13, 2017 at 5:47 am
Jeff Moden - Sunday, February 12, 2017 10:33 AMUnderstood but if you don't know that you shouldn't pass a "DOUBLE Word" to a "TinyInt", you're in deep Kimchi. 😉
Touche, sir. In that case, the page at https://msdn.microsoft.com/en-us/library/cc716729(v=vs.110).aspx in MSDN for .NET ought to work.
February 13, 2017 at 5:59 am
adonetok - Monday, February 13, 2017 5:56 AMThank you, Ed Wagner,
This is what I am looking for.
Glad to help. Thanks for the feedback.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply