|
Server Error in '/WebSite1' Application.
--------------------------------------------------------------------------------
Syntax error (missing operator) in query expression 'DOCTOR NAME = 'ankit''.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression 'DOCTOR NAME = 'ankit''.
Source Error:
Line 175: OleDbCommand cmd4 = new OleDbCommand(query,con1);
Line 176: //cmd4.ExecuteNonQuery
Line 177: dr = cmd4.ExecuteReader();
Line 178: if (dr.Read())
Line 179: {
Source File: c:\Users\Ankit\Documents\Visual Studio 2005\WebSites\WebSite1\Default2.aspx.cs Line: 177
my code is
tring connection1 = ConfigurationManager.AppSettings["conn"];
OleDbConnection con1 = new OleDbConnection(connection1);
con1.Open();
OleDbDataAdapter da = new OleDbDataAdapter();
DataSet ds = new DataSet();
OleDbDataReader dr;
string query="select COUNT(*) from appointment where DOCTOR NAME = '" + DropDownList1.SelectedItem + "' ";
OleDbCommand cmd4 = new OleDbCommand(query,con1);
//cmd4.ExecuteNonQuery
dr = cmd4.ExecuteReader();
if (dr.Read())
{
//if (Convert.ToInt16(dr[0]) != 4)
TextBox3.Text = "hello";
TextBox3.Text = dr[0].ToString();
}
|
|
|
|
|
Are you sure it should be 'DOCTOR NAME' with the space? As far as I know, SQL doesn't like having spaces in field names, or at least, not used in the way you have here.
Edit: Looking at your code below, this seems likely. Did you copy and paste this code snippet or copy it out by hand?
Also, try and avoid things like 'plz', it annoys people.
|
|
|
|
|
okk....i got it correct.the problem was with the field name itself.
|
|
|
|
|
You just asked this question, wait for a response or continue to post on that thread don't start a new one.
only two letters away from being an asset
|
|
|
|
|
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();
}
}
|
|
|
|