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 21:24pm
maan_k436
Edited 1-Jan-13 23:14pm
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)

  Print Answers RSS
0 Dnyaneshwar@Pune 1,300
1 Sergey Alexandrovich Kryukov 802
2 Tadit Dash 330
3 ravikhoda 300
4 OriginalGriff 272
0 Sergey Alexandrovich Kryukov 11,441
1 OriginalGriff 6,930
2 Peter Leow 4,850
3 Abhinav S 3,838
4 Maciej Los 3,575


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