Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
how to convert string to bigint in asp.net using c#.
 
I have taken Refid as Bigint.
So,i want to convert textbox value to BIGINT
 
Query = "select * from demo where Refid=" + __________(TextBox1.Text);
Posted 1-Jan-13 22:24pm
maan_k446
Edited 2-Jan-13 0:14am
digimanus32.4K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You query is going to work just fine without any conversion. Just make sure that the value entered in the textbox is validated before sending to the query.
  Permalink  
Comments
digimanus at 2-Jan-13 5:15am
   
he can use string.format to assist him:
Query = string.Format("select * from demo where Refid={0}", TextBox1.Text);
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
 
You can use the following things for conversion.
textboxvaluehere.ToInt64();
Convert.ToInt64(textbox value here);
 
Int64.Parse(textbox value here);
Int64.TryParse(your textbox value, out parameter);
 
Use any one of these method and you will get the integer to be parsed. But remember that your textbox contains a valid input.
 
Thanks
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Try this
 
 
Query = "select * from demo where Refid=" + Convert.ToInt64(TextBox1.Text);
 
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It is easiest to use Convert.ToInt e.g. select * from demo where Refid=" + Convert.ToInt64(TextBox1.Text); .
 
However, this can be a problem if you are not sure if the string is an integer.
In this case, you can consider using Int64.TryParse[^].
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

I think you no need to convert string to bigint.
Query = String.Format("select * from demo where Refid={0}" ,TextBox1.Text)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

hi,
 
Use this one :-
 
Int64 refId=0;
Int64.TryParse(TextBox1.Text, out refId);
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

You can use either Int64.TryParse or Convert.ToInt64
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.150302.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100