|
Nekshan wrote: dashboardid.ToString() is giving error. after dashboardid. -> tostring option does not cum.
His advice is totally wrong. Don't follow it.
Nekshan wrote: how can i convert a string type variable(having value int type) to integer?
string s = "10"
int n;
if (int.TryParse(s, out n))
{
// n now = 10
}
else
{
s was not a number
}
But, you won't get a single number out of the DB, you'll get a dataset, containing one data table, with a data row for each id that was returned.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
No, you are TOTALLY wrong. dashboardid is a column in his database. 10 is NOT a column in his database.
In fact, you don't need to call tostring when adding a number to a string, but in this case, your core advice is wrong.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi Graus,
i m trying this, but it does not seem to work out :
string s = cmd.CommandText = "select dashboardid from dashboardlogin where (loginname = 'nekshan') AND (loginpswd = 'engineer')";
cmd.CommandText = s;
cmd.CommandType = CommandType.Text;
int i = Convert.ToInt32(s); // giving error on this line
cmd.Connection = conn;
cmd.ExecuteNonQuery();
It gives error as : Input string was not in a correct format.
do i need to use dataset for it?
hope to get a reply.
thanx.
|
|
|
|
|
As Christian said before, you should definitely go out and buy you a book on C# and database programming.
Obviously, you still not get the idea that s is just a plain string that contains the text of your query, but the string itself cannot return the result of the query. That's what the classes inside the System.Data namespace are for. You already set up a SqlCommand instance in your code snippet, so why are you still trying to get the query result from the query string.? You should get the id by calling ExecuteScalar instead of ExecuteNonQuery on the SqlCommand instance and cast it to int. Take a look at the MSDN topic of the ExecuteScalar method; it contains an example that is similar to what you're trying to achieve.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
You are totally, utterly lost. If you can't understand what I've explained to you, that proves you're in over your depth. Work through a beginners book then come back to this stuff.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
SqlConnection conn=new SqlConnection("server=(local);Initial Catalog=Northwind;user id=istore;pwd=istore");
conn.Open();
SqlCommand cmd=new SqlCommand("select employeeid from employees where employeeid=1",conn);
Label1.Text=Convert.ToString(cmd.ExecuteScalar());
-------------
this code surely works
try it!!;P
|
|
|
|
|
SqlCommand cmd=new SqlCommand("select employeeid from employees where employeeid=1",conn);
Label1.Text=Convert.ToString(cmd.ExecuteScalar());
employeeid is an int in db.
answer is coming in label, but if i put a variable like dis :
int s = Convert.ToString(cm.ExecuteScalar());it gives error : Cannot implicitly convert type 'string' to 'int'.
if i put variable like:
string s = Convert.ToString(cm.ExecuteScalar());
it gives error : Cannot convert from 'string' to 'int', in the below function.
as i have to display dis employeeid ie 's' in a function:
funEntrylogin(s, tb_id.Text, tb_pswd.Text, DateTime.Now, DateTime.Now);
|
|
|
|
|
Hi!
I have to implement CSS in my C# asp.net web application.
I made a Css class and used it in my aspx form. But formatting is applied only on backgroud of the form. formatting on the web controls like buttons and labels is not applied. Can anyone guide me to solve this problem.
Thanx
|
|
|
|
|
This is not a C# question, it belongs in the web development forum ( as it has nothing to do with ASP.NET, or C# ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
anyone have an idea how to concatenate SortedLists? and also get its half?
for example say i have SortedLists s1, s2, s3. I would like to add all the top/end halves of each SortedLists into a single one, say sTotal;
thanks!
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
Please, could anyone send me a C# source code to draw an ellipse by pressing a button?
Thank you very much.
Saludos, Giovanni
|
|
|
|
|
Why would you ask this again, when your original message is two posts down ? Why not read what I suggested ? If you can't follow my explanation, ask me. If you're incapable of writing this yourself, give up on working at this level of complexity and do some work to bring yourself up to this level by studying something more at your level.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If you believe you are a genius, why don't answer to the specific question?.
Else avoid answer me.
Saludos, Giovanni
|
|
|
|
|
I didn't say I was a genius. I *did* answer your question.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi!
i have to use media player control to play video clips. I have found no control for it. Actually i dont want to code in asp.So can anyone help me in using control and its coding in C#.
waiting for urgent reply.
Thanx
|
|
|
|
|
If you're using ASP.NET, then you need to embedd it using HTML. C# won't help you at all, as the C# code runs on the server, not the client.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Please, help me:
I need to draw an ellipse, which parameters must be stablished in textboxes, and when pressing on a button can draw an ellipse (or another geometric) with the parameters of the textboxes.
Also, if I change some parameter in some textbox, and then by pressing again on the button, the ellipse should change according to the new parameters.
Thank you very much.
Saludos, Giovanni
|
|
|
|
|
You need to add a paint handler, that shuold check your textboxes, using int.TryParse to see if they contain numbers. If they do, use them to draw your ellipse, using the Graphics object passed in on the event args.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
use C#+asp.net+Sql Server2000 all sourcecode opened
good learn tools
www.drpsky.com
your friend
|
|
|
|
|
If you want to advertise your site, contact the sys admin for pricing on advertising.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello, recently I have been toying around with the System.Drawing namespace. But it does not seem that it ever updates even if it is in an onPaint event handler.
This is all the code i put in the entire class. I changed nothing else.
public partial class Form1 : Form
{
int Cheese = 1;
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics MyGraphics = e.Graphics;
Brush MyBrush = Brushes.Aqua;
Font MyFont = new Font(FontFamily.GenericSansSerif, 12);
MyGraphics.DrawString(System.Convert.ToString(Cheese), MyFont, MyBrush, 10, 10);
Cheese = Cheese + 1;
}
}
What should i be doing?
(The output is constantly "1")
Thanks.
|
|
|
|
|
Call Invalidate() to force a paint event, in a button handler, and it will work.
Use Cheese.ToString() instead of Convert.ToString. Or " " + Cheese, will also work.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
It's because the window only paints itself once unless there's reason to repaint it again. For example, the number should increase if you hide the window (maybe minimize it), then reshow the window. It will have repainted a number of times.
FYI, you can force a paint in code using the Invalidate() method of the Form class. Invalidate tells the operating system that a repaint is needed, and it will repaint at the next opportunity.
|
|
|
|
|
Hi,
I am developing windows mobile application using vs05 C#.NET..
How to install exe file with icon/logo to Windows Mobile programs collection or main menu?
I want to put my exe file icon in Start/ Programs/ ...Directly can i click the icon in programs? please help me...I am new in the field.
Thanks in advance..
Bye
|
|
|
|
|
Can I please help to know, how to pass a reference from your command class to a windows user ?
Can any body give me a code?
Thanks
Kedie
|
|
|
|