|
Arguably, it is a different error. Same set of code though.
|
|
|
|
|
Hi i m developing windows application in C#.net,where i m using datagridview. i want to disply only some of column when the application get execute. right now im storing the column header text, width and displayindex in textfile.and at the time of execute i read the textfile and apply thos header text, width and displayindex to the datagridview
but not displaying in proper manner
plz help me..
thanks
|
|
|
|
|
Do you want to hide the columns, that you dont need ?
If yes :
Sample :
dataGridView1.Columns[1].Visible = false;
|
|
|
|
|
I am using MS VS 2008 and can find the ListView property ContextMenuStrip, but no property for ContextMenu.
How can I activate (show) a ContextMenu when I right-click my ListView please?
|
|
|
|
|
You must set it using code :
listView1.ContextMenu = ... // place your context menu here.
It doesn't show in property windows, because ContextMenu is replaced using ContextMenuStrip since VS2005.
|
|
|
|
|
Many thanks for the heads up. Much appreciated.
|
|
|
|
|
hi,
I was not sure whether to post this message in database forum or C#, plz guide.
I have developed a simple database application which reads records from table and displays them in grid, it runs fine on my system but when I try to run it on client's machine it either gives exception or just crashes. It seems that there is some issue in connection string but I have not been able to identify..
here's some information:
Connection String: Data Source=.\SQLEXPRESS;AttachDbFilename=D:\dev\POS\POS\bin\Release\POS_DB.mdf;Integrated Security=True;User Instance=True;Connect Timeout=200
Exception: "The timeout period elapsed prior to completion of the operation or the server is not responding."
I have tried many things but nothing worked, any kind of help will be appreciated. Thanks,
Regards,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
Things that occur to me. I'm sure that you will have checked them anyway, but it does no harm to have a reminder.
1) is the SqlExpress on the clients machine running?
2) was it installed with the same settings as the one on your machine?
3) unlikely, but is the path correct? (you should get a different error, if so, but worth checking)
If I think of any others I'll post again.
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.”
|
|
|
|
|
hi Henry,
thanks for reply. i dint knew that SQL Express should be installed on client machine. I havnt installed it on client machine, i will try it. Can you please elaborate how can I install SQL Express having same setting? Thanks,
Regards,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
For the application to run on the clients machine, it must have access to an Sql Server instance. If one is already there, either on the machine or on the network, then simply change the '.\SQLEXPRESS' part of your connection string to the name of that Sql Server. If not, then install SqlExpress. The biggest problem you will have is to remember the settings you used on your own machine. Unless you can remember exactly how you did it, just go for the defaults and try it. Don't forget to copy the *.mdf and *.ldf files, unless your application creates them or the installer does it for you.
Good luck!
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.”
|
|
|
|
|
string connection1 = ConfigurationManager.AppSettings["conn"];
OleDbConnection con1 = new OleDbConnection(connection1);
con1.Open();
OleDbDataAdapter da = new OleDbDataAdapter();
DataSet ds = new DataSet();
OleDbDataReader dr;
OleDbCommand cmd4 = new OleDbCommand("select count(*) from appointment where DOCTOR_NAME = '" + DropDownList1.SelectedItem + "' ";", con1);
dr = cmd4.ExecuteReader();
if (Convert.ToInt32(dr[0]) != 4)
TextBox4.Text = "hello";
am tryin this code but its showing error in the run time.
the error is
Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.
Source Error:
Line 173:
Line 174: OleDbCommand cmd4 = new OleDbCommand("select count(*) from appointment where DOCTOR_NAME = '" + DropDownList1.SelectedItem + "' ", con1);
Line 175: dr = cmd4.ExecuteReader();
Line 176: if (Convert.ToInt32(dr[0]) != 4)
Line 177: TextBox4.Text = "hello";
can u help me out
|
|
|
|
|
Hi,
is ExecuteReader() the right method to call, your query seems to produce only one number?
BTW: when a complex expression (such as the query string) is involved in a problem statement, I suggest you calculate the expression beforehand and print it out, e.g. using Console.WriteLine, to have a careful look at it (don't use Visual Studio's watch for this, it is confusing everyone with quotes and double quotes).
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.
|
|
|
|
|
thank you sir....actually i only want the value of the count.how can i get it in some variable.
|
|
|
|
|
Have a look at ExecuteScalar and ExecuteNonQuery; one of those should fit your purpose.
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.
|
|
|
|
|
Replace
OleDbCommand cmd4 = new OleDbCommand("select count(*) from appointment where DOCTOR_NAME = '" + DropDownList1.SelectedItem + "' ";", con1);
with
<br />
OleDbCommand cmd4 = new OleDbCommand("select count(*) from appointment where DOCTOR_NAME = '" + DropDownList1.SelectedItem.Text + "'", con1);
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
its still not workin sir...
the error is
Line 173:
Line 174: OleDbCommand cmd4 = new OleDbCommand("select count(*) from appointment where DOCTOR_NAME = '" + DropDownList1.SelectedItem.Text + "' ", con1);
Line 175: dr = cmd4.ExecuteReader();
Line 176: //if (Convert.ToInt16(dr[0]) != 4)
Line 177: TextBox4.Text=dr[0].ToString();
|
|
|
|
|
Dear All, I have a shared assembly which i can access it from several application.
now i would like to make setup of all these application into a package.
can i bind or package my shared assembly with setup probject?
i am using simple wizard of vs2k5 to create setup project.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
As long as you have included a reference to the assembly, it should be packaged and install correctly (to the application directory). Note that there re things you can do to stop this, so if the assembly you included do not install, then you have an incorrect setting somewhere.
Note that some common assemblies (e.g. the core .net framework ones such as System, System.Core) are installed into the Global Assembly Cache (GAC), and will not installed into the application folder.
Hope this answers your question!
|
|
|
|
|
thanks alot, infact i was afraid if the key for shared assembly can be installed with it (very funny).
thanks a lot.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Im not sure if i did the right thing to post here, i went through a few threads and i couldnt figure this thing out. sorry it's my first message, also im just learning c# and i have no idea wat error i have..
Should i post this somewhere else or create a message everytime?
This is my program:
using System;
class Work1
{
public static void Main()
{
int amount;
Console.WriteLine("Enter wage");
int wage = Console.ReadLine();
Console.WriteLine("Enter hours");
int hours = Console.ReadLine();
amount = (hours * wage);
Console.WriteLine("Amount = ", amount);
Console.ReadLine();
}
}
Im trying to learn c# and tried something very simple. wage*hours = my money. but of course i failed doing so.
Error 1 Cannot implicitly convert type 'string' to 'int' C:\Users\Saliba\Documents\Visual Studio 2008\Projects\Project2\Project2\Class1.cs 12 19 Project2
//refers to this line = int wage = Console.ReadLine();
Error 2 Cannot implicitly convert type 'string' to 'int' C:\Users\Saliba\Documents\Visual Studio 2008\Projects\Project2\Project2\Class1.cs 15 25 Project2
//refers to this line = int hours = Console.ReadLine();
those are the errors.
i know its pretty frustrating for admins and moderators to stay deleting/ moving posts. im sorry if this is the case.
thanks for future help, Luke
|
|
|
|
|
class Work1
{
public static void Main()
{
int amount;
Console.WriteLine("Enter wage");
int wage = int.Parse(Console.ReadLine());
Console.WriteLine("Enter hours");
int hours = int.Parse(Console.ReadLine());
amount = (hours * wage);
Console.WriteLine("Amount = {0}", amount);
Console.ReadLine();
}
}
|
|
|
|
|
Console.ReadLine() returns a string, which can't be automatically turned into an int. You'll need to use Int32.Parse() to do that (see msdn for more details and examples)
|
|
|
|
|
Hi,
welcome to CodeProject.
your post is OK, it is in the right place; no one is going to move or delete it, even when fully answered.
and neither should you, according to these guidelines[^]. The one thing you forgot to do is apply PRE tags to improve readability of your code snippet.
Your code shows two errors, you should take the error messages literally, they say "hey, here is a string and you want to treat it as an integer, I can't do that". And yes, that is what is going on as Console.ReadLine() returns a string, and you want to store it in an int.
This is a beginner's mistake; changing some type into some other type most often needs an explicit conversion; that could be either a cast (on inheritance up/downcasting), a call to a method of the Convert class (seldom really useful), or a call to a method of the destination's type class (most often).
So what you want here is int.Parse() with an explicit try-catch construct, or better yet int.TryPatse() Look those up in the MSDN documentation, make google your friend!
And if you aren't familiar with any of this, I strongly recommend buying and studying a book on C#. Here is
why[^].
Cheers.
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.
|
|
|
|
|
First of all just to let you know that console.ReadLine returns a string value so when it returns string value you can't directly assign it to and integer you should convert it to int
try
int x = Convert.toInt32(Console.ReadLine());
in console.WriteLine add the ".ToString()" so it would convert it to string so you could print it.
|
|
|
|
|
One more suggestion: tell your IDE to always show line numbers in editor windows; that way it is a lot easier to deal with compile-time and run-time errors. For Visual Studio look here[^].
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.
|
|
|
|