|
That is the primary reason I encourage (require) programmers on my teams not to use int and long in C# and instead require Int32 and Int64. The same issue comes up a lot in database programming. I am absolutely sick and tired of seeing cast errors in code because a programmer doesn't know what type they are using.
|
|
|
|
|
|
Hi,
I have a string with value "111733394601234567094987654321" . Now i want to divide this with 636. I convert it to double , then im getting 1.1173339460123456E+29 . but these both values are differnt finally im
getting wrong output. can anyone help me.....
Thanks
Prathap
|
|
|
|
|
There is no way you can do that with doubles. Since the value is too big even for a 64 bit integer, you should use some 128-bit integer class. See for example this[^] or Google for some more.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
The latest .NET 4.0 (and Visual Studio 2010) is in beta and offers a BitInteger class which would easily take care of your big integer division, yielding accurate quotient and remainder values.
There also have been some articles on home-brew BigInteger classes here on CP (with varying functionality and quality).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi, my database has a column called 'course'. I have a value "Game & Entertainment Technology"
when i extract the value using
acc.Course = reader.GetValue(4).ToString();<br />
lblCourse.Text += " " + acc.Course.ToString();
the value becomes Game Entertainment Technology.. the & disappear
|
|
|
|
|
That's because & is used to underline a letter for a shortcut. You need to double it to &&.
acc.Course = reader.GetValue(4).ToString();
lblCourse.Text += " " + acc.Course.ToString().Replace("&", "&&");
Regards,
Rob Philpott.
|
|
|
|
|
Actually, presuming reader is a SqlDataReader and acc.Course is a string you can shorten this to:
acc.Course = reader.GetString(4);
lblCourse.Text += " " + acc.Course.Replace("&", "&&");
Regards,
Rob Philpott.
|
|
|
|
|
thanks alot!
1 more question. My first screen is a login screen. Therefore i have a username and password textbox.
private void btnLogin_Click_1(object sender, EventArgs e)<br />
{<br />
bool validate = db.authenticate(tbxUsername.Text, tbxPassword.Text);<br />
if (!validate)<br />
{<br />
MessageBox.Show("Invalid Credentials");<br />
}<br />
else<br />
{<br />
frmMain main = new frmMain(tbxUsername.Text);<br />
<br />
main.Show();<br />
this.Hide();<br />
<br />
}<br />
}
Is it possible to close the login form instead of hiding it? I do a this.close() but after i login everything close.
Also, my db.authenticate is not case sensitive. The password in the database is 'test'. However when i entered 'TEST', it works too.
|
|
|
|
|
If the login form is the first one created and called from Program.cs, the application classes it as the 'Main' form of the application. When the main form closes, the application closes.
There are loads of examples of using a login form on the web, have a quick google to see how to do it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Okay. Noted. Thanks
What bout make the password and username case sensitive?
|
|
|
|
|
You stated that db.authenticate was not case sensitive. I can not find any reference to an authenticate method for any database related classes, so I assume that it is one you have written yourself.
If that is so, take a look at this[^].
I not, I am unable to help.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thanks. i found the solution.
inside phpmyadmin, i change the collation to latin1_general_cs.
cs refers to case sensitive
|
|
|
|
|
Certainly you'd want to close the login screen when you're finished with it. There are a few ways to do this. Also, you don't want to do a main.Show() in the login screen - you lose reuse and abstraction if you do that by tightly coupling the login and main screen.
To open the main screen after the login either call ShowDialog() on the login form from the main form's on load event or you can change your main() function to look like this:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new LoginForm());
Application.Run(new MainForm());
}
Regards,
Rob Philpott.
|
|
|
|
|
Ampersand "&" is used as a special character in Windows Forms controls: it will cause the next character to be underlined. You can solve your problem by replacing each ampersand with a double ampersand.
Try something like:
lblCourse.Text += " " + acc.Course.ToString().Replace("&", "&&");
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
I'm trying to connect to Sybase Server (Adaptive Server Anywhere 6.0) from my C# application but failed to establish a connection.... it seems the C# use a default MSSQL driver. Below is the error:
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
below is the code:
//string bartsConnect = "Driver={Adaptive Server Anywhere 6.0};SRVR=MyServer;DB=MyDatabase;UID=myUserId;PWD=myPassword";
string myConnection = "server=ServerName;Database=myDatabase;uid=myUserId;pwd=myPassword";
SqlConnection myConnection = new SqlConnection(myConnection);
myConnection.Open();
hope to hear some answers soon,,,, thank you.
xxx
|
|
|
|
|
You are using an SqlConnection , which is specifically for SQL Server.
Try to use an OleDbConnection and you should be all right.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
yes, thank you but my problem is the connection string that i can be use to connect to Sybase(Adaptive Server Anywhere 6.0)... most of the examples in the net use access database..... can u give me the right connection string for the above server?...
xxx
|
|
|
|
|
Sorry I have no experience with Sybase, so I cannot help you with connection strings.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
|
I am trying to make a button to represent a volume control knob such as on a CD player in c#
The following error has croped up and i cant find any "Useful" information on what could be wrong.
Does anyone know how to resolve this Exception:
"WindowsFormsControlLibrary1.dll' doesn't contain any UserControl types."
Why would the namespace not contain a user control or could i have not linked the dll properly?
Thanx
|
|
|
|
|
I guess you get this error when you try to run your solution (F5) inside Visual Studio.
You cannot directly run a dll, you should set up an executable project in your solution and make it the "Startup Project" for the solution.
For example, create a new Windows Form executable and link your dll in it, in order to test your custom button.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
I've never seen such an exception before so have been looking around. Some people who've had this problem were trying to start the wrong project in the solution. Could this be it?
Don't understand that though, as if you try to start a .dll Visual Studio tells you not to be so stupid, and not with those words.
Regards,
Rob Philpott.
|
|
|
|
|
Thanx for the help.
I was thinking along those lines just before you posted.
I made a new project and linked to the user control i had creted to it, my button didnt do what it was meant to (due to my coding abitlity) although it did compile.
I think it may be because i had a form in the user command project to show its asthetics, and tried to run it on that which did not work.
may need to start a new thread on the functionality now thought.
Solved thanx for helping.
|
|
|
|
|
Hi !
I am looking for a tool to automatically encapsulate C++ library into C#.
I found some tutorials which tell me to first encapsulate classes in C++/CLI and then I could invoke my managed c++ classes into my C# project. But that's a lot of dummy work! I think automatics tools exist but I can't find them
Any suggestions ?
Thanks.
|
|
|
|