shayankhan 0 Newbie Poster

well i used TOP 1 before the sum() functions and now its working ..
thanks for helping me out.

shayankhan 0 Newbie Poster

I am getting error

Incorrect syntax near 'LIMIT'.

i am using sql 2008

shayankhan 0 Newbie Poster

Hello guys i am little bit confuse here with the code
can any one help me out ..
i want max customer paid in shopping and their name
i dont know that i am using right way or not but guide me here

Select sum(od.unitprice * od.quantity) as Amount,
        (Select ContactName from Customers where customerId in (o.customerid)) as CustomerName  from [Order Details] as od
        inner join orders as o on o.orderid = od.orderid
        inner join customers as c on o.customerid = c.customerid
group by o.customerid

here if i use

Max(sum(od.unitprice * od.quantity)) as Amount

i get error can you please correct the code... i want the customer name
who have paid amount very much.

shayankhan 0 Newbie Poster

ohhhhhh i am so sorry for this thread
i got what was the error .. please close this thread
well the error was
'" + cno + "'"
' ' means character while my autonumber contains integer
sorry. and thanks

shayankhan 0 Newbie Poster

Hello again guys,

I am little bit stuck in this situation and searched everywhere in google
but i did'nt find what actually i want..

a problem with autonumber in access database. i have created a database with 4 columns .. deleted primary key slip, cname, nic... the slip column is autonumber (not primary key).
heres my code and the error..

i want that when i enter slip number in textbox it searchs the slip no in the database
of slip column.. but i dont know whats the problem here.

and please tell me what is difference between oledbdatadapter and olebdcommand and oldbcommandreader.

ERROR:
{"Data type mismatch in criteria expression."}

Code:

long cno = Convert.ToInt64(textBox3.text);
  OleDbConnection connect = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source = customers.mdb");
  OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from Customer where Slip='" + cno + "'", this.connect);
 OleDbCommand read= new OleDbCommand("Select * from Customer where Slip='" + cno + "'", this.connect);

  this.connect.Open();
  object existentry = read.ExecuteScalar();
  if (existentry == null)
      {
        MessageBox.Show("Slip number not found.");
        return;
      }
   else
      {
        // blah blah code,
      }
this.Close();
shayankhan 0 Newbie Poster

hirushan ok thanks for your help can i ask 1 more question..
if you dont mind


i want that if date is found in table then it retrieve the column 3 value .
means if date is in column 1 and row 2 .. so that the value of column 3 raw 2 is returned.
or save in any string or int.

shayankhan 0 Newbie Poster

Hello i am making my project i am stuck at searching two strings in database
for example my table [hotel] contains columns

[Date] [Room Size] [Meal] [Car]

i want to search for date + room size too.

my code checks only [Date] but not [Room Size]

and i want that if some one puts "12 Dec" (as search string) and in second textbox "4"
first it checks date and then availability for room size and return the room size value.

hope everyone understand my problem.

string date = textBox1.Text;
            string room = textbox1.text
            loaddata = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=Hotel.mdb");
            data = new OleDbDataAdapter("Select * from [hotel] where (Date='" + PNR + "')", loaddata);

so far my date code works

shayankhan 0 Newbie Poster

ohhhhhhhh GOD i did it !!!
here what i was talking unimportant

pc[1].copydefault(pc[1] , pc[0]);

copydefault function will send two objects
and then object_1 (2 strings name agp) and (1 int lcd) value are copied to object_2
while object_1 contains 5 strings 2 int.

void copydefault(automobile &pc_1, automobile &pc_O) {
		pc_1.name = pc_O.name;
		pc_1.agp = pc_O.agp;
		pc_1.lcd = pc_O.lcd;
}

unimportant thanks about contruct and pointer actually i directly jumped
to OOP without clearing my concept of pointers & references.

shayankhan 0 Newbie Poster

unimportant thanks for the help and guide ... these codes works perfect.. but you know
these are just objects that created, but my actual work is in array object.

comptr *pc = new comptr[49]; //range 1-50
as when i code this
pc[0]. blah blah();

pc[1]=pc[0];        <---- this copy all variables from pc[0] array.
comptr pc[1]=pc[0]; <------- this give me (IntelliSense: initialization with '{...}'
                                 expected for aggregate object)

i think there is no way to get array1 objects specific items and put into array 2 objects.
i search everywhere but no use so i will change my mind and code into simple 2 objects not array objects.
i really appreciate your help...

shayankhan 0 Newbie Poster

unimportant ... i dont know how to copy array contents to other array using constructor... i will try my best...

shayankhan 0 Newbie Poster
cmptr pc[1]=pc[0]; // this is a redefinition
pc[1] = pc[0]; // this is what you actually wanted, assuming a was at least 2

cmptr *pc = new cmptr[100]; // this would be a = 100
pc[0].defaultinfo(); // both totally ok
pc[99].defaultinfo(); // both totally ok
// pc is a pointer to memory segment containing 100 copies of the cmptr object in sequential order
// the number you pass to the [] operator is an "offset", which adds the size of an object in bytes to the address of pointer &array[0]
// so, &pc + 100 bytes might be pc[1] if each object is 100 bytes in memory, but this is kind of semantics

// hence:
cmptr pc[1]; // is totally wrong, you already gave pc[1] a definition.

// Edit: don't forget to delete the memory pc points to when you are done using it:
delete[] pc;

Good luck!

pc[1] = pc[0]; // this is what you actually wanted, assuming a was at least 2

pc[0] whole contents are copied to pc[1] ... but i want 3 contents to be copy. i mean agp, name of pc, and lcd just copy to pc[1]
please look what i am talking about
and thanks for the advice and guide for deleting array memory ...

shayankhan 0 Newbie Poster

Hello guys i am in level of class and objects
i need some help and guide in copy contruct i search the thread
and found 1 http://www.daniweb.com/forums/thread21662.html
but this is not what i want... ok here is the problem..

i created contruct class ... i want in program that create objects
on user input.. like how many computer you need.. if user enter 5
then compiler create 5 objects of class computer.. after that it asks
for computer specification and compiler then copy some contents to other
4 objects ... i coded the program it works perfect but the copy method copies
every contents of 1st object into others.. how can i copy some contents ..
this scenario is done with array object. please guide me if there is any better idea.

#include "iostream"
#include "string"
using namespace std;
class cmptr
{
private:
	string rm;
	string hd;
	string nme;
	string agp;
	string mothrbrd;
	int lcd;
	int pcr;
public:
	void defaultinfo()
	{
		cout<<"PC SPEC ";
		cout<<"Enter pc name: ";
		cin>>name;
		cout<<"Enter processor speed: ";
		cin>>pcr;
		cout<<"Enter ram size: ";
		cin>>ram;
		cout<<"Enter motherboard model: ";
		cin>>mothrbrd;
		cout<<"Enter graphics card size: ";
		cin>>agp;
		cout<<"Enter lcd size: ";
		cin>>lcd;
	}

	void all_other_info()
	{
		cout<<"Enter processor speed: ";
		cin>>pcr;
		cout<<"Enter ram size: ";
		cin>>ram;
		cout<<"Enter motherboard model: ";
		cin>>mothrbrd;
	}

	void display()
	{
		cout<<"pc name: "<<name;
		cout<<"processor speed:"<<pcr;
		cout<<"ram size: "<<ram;
		cout<<"motherboard model: "<<mothrbrd;
		cout<<"graphics card size: "<<agp;
		cout<<"lcd size: "<<lcd;
	} …
shayankhan 0 Newbie Poster

thanks for the guide .. i will look shadowscripter codes and try to understand too .. :)
and thanks for the last help .

shayankhan 0 Newbie Poster

hmmmmmm i'll try this too ... but what if per person whole information is saved in one line
and i have 4 person information ... and i want to to read each line so that i get rid of 4 loops ....
i am just figuring out because my code looks awkward .. i am trying to do my best..

thanks ///

shayankhan 0 Newbie Poster

thats great ..!!! work perfectly .. but i know this is not the way to code perfect.. but i am at beginner level .. even i don't know what is class members.. and blah blah all i know ,, 2 dimension array .. string .... loops :)
but thanks for guiding me ..

i have one more question .. there is one thread but i donot want to hijack other user thread.

question is i have text file
and as you see my above coding is like reading line then write what was read... and it reads 4 times
my address book save data like this.

Name: Jhon Cena
Father Name: Ninja Turtle
Age: 22
Mob No: 654654
Email: microsoft dot com

my code find 'Name:' in text file
and if it is found. then the code read 4 lines more to get other information

if i can save my information like this

Name:Jhon Cena Father Name: Ninja Turtle Age: 22 Mob No: 654654 Email: microsoft dot com

now how can i read this above line and put them into text boxes
i read about 'strtok' but my concept was not much clear... can you guide me little??

thanks again :)

shayankhan 0 Newbie Poster

Hey Guys!!!!

I am searching everywhere but i did'nt find actual answer from internet or may b I am wrong..
I am making a program that stores data.. my all program works perfectly but there is one problem
i cannot solve.. i am new to WINDOWS FORM (Object ORIENTED) and i directly jumped from console
version to WINDOWS version.. coming to topic ...

I have LISTBOX1 and EDIT and SAVE button when i select name in List box and press EDIT button
all information is retrieved and set in textboxes.. but i want that the selected name in LISTBOX
make a global variable and so that when i want variable i get from global variable ?? how can i do this
here is my code../

private: System::Void edit_button(System::Object^  sender, System::EventArgs^  e) {
			GetData();
		 }

	private: System::Void GetData() {
				String^ SelItem;
				SelItem = listBox1->SelectedItem->ToString();
			StreamReader^ ReadFile = gcnew StreamReader("addressbook.txt");
			String^ LineData;
			while (ReadFile->Peek() >= 0) {
			LineData = ReadFile->ReadLine();
			if (LineData->Contains(SelItem) == true) 
				{ 
					textBox1->Text = LineData->ToString(); 
					LineData = ReadFile->ReadLine();
					textBox2->Text= LineData->ToString();
					LineData = ReadFile->ReadLine();
					textBox3->Text= LineData->ToString();
					LineData = ReadFile->ReadLine();
					textBox4->Text= LineData->ToString();
					LineData = ReadFile->ReadLine();
					textBox5->Text= LineData->ToString();
			}
		}
		ReadFile->Close();
	 }

	private: System::Void save_edited(System::Object^  sender, System::EventArgs^  e) {
            here i want SelItem how can i get this from edit_button 
              i dont want listbox1 selected item .. i want SelItem string value that was created in
              edit_button ... how can i pass this variable to save_edited button ?? 
 
        }

Thanks In advance.. and …

shayankhan 0 Newbie Poster

thanks for the guide i was not aware of string array ... i thought char array is also called string array ..
thanks again aranarth

shayankhan 0 Newbie Poster

Hello guys ...
can anyone help me or guide me if i am thinking wrong,
can we copy character array into character array.
like

char names[250];
cin>>names;
names=names+names;

like we do with
int a;
cin>>a;
a=a+a;

can we do this with character array

i want to store 7 names into one charracter array using loop e.g.

char names[250];
int i=1
while(i<=7)
{
 cin>>names;
 names=names + names;
 i++
}

this is not working with me .. any other way ?
and how i then print out seperate names ..?