|
Hi,
Connection is disconnected because socket (address and port) is not valid any longer.
-----------
Mila
|
|
|
|
|
This is what I think but I have a colleague that says when the conncetion between two server is up throgh a socket, even though the ip changes for one server the connection should be there. And any new connection should use the new ip address not the one that is already there.
|
|
|
|
|
I just tried changing the IP on a LAN and the TCP/IP connection dropped.
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
|
Hi,
I am having a CDBException in my code which access sql server databse from VC6.
CDatabase pData;
CString strConnectionStr="Driver={SQL Server}; Server=local;Database=Northwind; UID=sa; PWD=sa;";
CString strSqlQuery=" update Employees set city='LondonUK' where city='london'";
try
{
pData.Open(NULL,false,false,strConnectionStr);
}
catch(CDBException* dbExcep)
{
dbExcep->ReportError();
return 0;
}
try
{
pData.ExecuteSQL(strSqlQuery);
}
catch(CDBException* dbExcep)
{
AfxMessageBox(dbExcep->m_strError);
switch( dbExcep->m_nRetCode)
{
case AFX_SQL_ERROR_API_CONFORMANCE :
AfxMessageBox("AFX_SQL_ERROR_API_CONFORMANCE");
break;
case AFX_SQL_ERROR_CONNECT_FAIL:
AfxMessageBox("Connection to the data source failed");
break;
case SQL_INVALID_HANDLE:
AfxMessageBox("Sql invalid handle");
break;
default :
AfxMessageBox("no result");
}
return 0;
}
in switch, result is SQL_INVALID_HANDLE.
Plz tell me where is the problem.
Cyber Friend
|
|
|
|
|
What is the error message? I see you display one of te strings in a messagebox.
What's the message?
Try adding this to your catch block and see the error details...
TRACE(_T("** %s \n"), dbExcep->m_strError);
TRACE(_T("** %s \n"), dbExcep->m_strStateNativeOrigin);
Also don't forget to delete the exception object
dbExcep->Delete();
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Hi,
Thanx mark for your reply.
Mark there is no error msg , both strings are empty, i have checked them after debugging too. I can determine the error only from dbExcep->m_nRetCode in switch statement, which shows this msg.
case SQL_INVALID_HANDLE:
AfxMessageBox("Sql invalid handle");
break;
One important thing is that I recieve a "Debug assertion failed" when i try to delete dbExcep on this line.
<br />
delete dbExcep;<br />
Cyber Friend
|
|
|
|
|
Cyber Friend wrote: there is no error msg , both strings are empty,
That's awfully helpful of the driver
Oh well, glad you found it!
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Hi,
I have solved the problem by using CDatabase::OpenEx(strCon).
Thanx to all who participated in this thread.
best regards,
cyber friend
|
|
|
|
|
Cool
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Cyber Friend wrote: CString strSqlQuery=" update Employees set city='LondonUK' where city='london'";
No Sure though , try modifying this to,
CString strSqlQuery=" update Employees set city= \"LondonUK\" where city=\"london\"";
-- modified at 0:22 Friday 23rd February, 2007
In fact it doesn't seem to be problem. But this particular error comes due to programming error,as MSDN indicates.
|
|
|
|
|
Hi,
Parasad thanx for your reply.
I have tested the same query on an Access database with connection string for access.I am sure that this query is ok bcoz i have tested it in Query analyzer for SQL Server too.
Best regards,
Cyber Friend.
|
|
|
|
|
hi want change virtual key code from ascii(65) to ascii(235) in my windows hook dll.
i able to do upto ascii(127) i.e. 7 bit but not 8th bit. can any one help how to do so.
i am also looking solution for ascii to unicode.
thank you
viral
|
|
|
|
|
viral_umang@hotmail.com wrote: hi want change virtual key code from ascii(65) to ascii(235) in my windows hook dll.
i able to do upto ascii(127) i.e. 7 bit but not 8th bit. can any one help how to do so.
I don't know what you are trying to do but it looks like you are using a char instead of an unsigned char. A char is signed so it goes up to 127 and not 255.
|
|
|
|
|
hi,
thank you very much to reply so fast.
i am from india, i have created keyboard hook for changing the keyboard's key's from
say 'a' to 'b' so, i am able to get 'b' when i press key 'a' of my keyboard.
I am able to do this by changing the vitrual keycode in my hook procedure.
so i want now is that i should get a font's symbol at 235 but i am not able to get the
virtual key code for ascii 235.
thanks,
Viral
|
|
|
|
|
Well, you don't provide a lot of information do you ? Did you check what I said in my previous post ? Can you post the code because it is impossible what you did wrong by just guessing it.
|
|
|
|
|
viral_umang@hotmail.com wrote: i able to do upto ascii(127) i.e. 7 bit but not 8th bit. can any one help how to do so.
Wat r u using , char, try using TCHAR.
Apurv
|
|
|
|
|
Hi all,
Its a simple console application to calculate quotation. Well its working fine but problem i am facing is i want to store the quotation to the file everytime when entered and also i want the text file to be displayed as output with all the entries made in past....
This structure should contain all the customer record details ..
struct Quotes
{
int QuoteNumber;
char Name[20];
int DeliveryCost;
int CarpetCost;
short Guarantee;
};
The below functtion displays final output(quotation) for the user who just entered his details...
void DisplayRecord(int QuoteNum, char Name[], float Cost, float DeliveryCharge, int GuaranteePeriod )
{
cout << setfill(' ')
<< setw(7) << QuoteNum << " | "
<< setw(NAME_COL_WIDTH) << Name << " | "
<< setw(1) << POUND_SIGN << setw(COST_COL_WIDTH-4) << Cost << " | "
<< setw(1) << POUND_SIGN << setw(DELIVERY_COL_WIDTH-4) << DeliveryCharge << " | "
<< setw(1) << POUND_SIGN << setw(TOTAL_COL_WIDTH-1) << Cost + DeliveryCharge << " | "
<< setw(7) << "Years: " << setw(GUARANTEE_COL_WIDTH) << GuaranteePeriod << " | "
<< endl;
}
Now there is a file containing quotation of previous customers, and i can access all the data through below mentioned coding...
But the problem is that i am unable to include this peace of code with rest of the program.
At present, user enter details and he recieves output of the total cost n all and nothing else happens...now i want the details to be stored to the text file and also it can be displayed frm the stored text file as output...
InFile.open("Quotes.txt", ios::in);
if(InFile.is_open())
{
while(!InFile.eof())
{
InFile.getline(Buffer, BUFF_LEN);
Customer[CustNum].QuoteNumber = atoi(Buffer);
InFile.getline(Buffer, BUFF_LEN);
strcpy(Customer[CustNum].Name, Buffer);
InFile.getline(Buffer, BUFF_LEN);
Customer[CustNum].DeliveryCost = atoi(Buffer);
InFile.getline(Buffer, BUFF_LEN);
Customer[CustNum].CarpetCost = atoi(Buffer);
InFile.getline(Buffer, BUFF_LEN);
Customer[CustNum].Guarantee = atoi(Buffer);
CustNum++;
}
}
Can any one help me out in this. I have not written code for storing data to text file yet but once ill get the above problem working i.e. to read the past entries frm text file as output, then i would continue further.
the text file format is exactly like structure created i.e.
QuoteNumber
Name
DeliveryCost
CarpetCost
Guarantee
Any or all help would be greatly appreciated...
Thanks a lot for giving your valuable time to this thread...
|
|
|
|
|
Why not use the ReadFile function instead?
BOOL ReadFile(
HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped
);
I.E.
HANDLE hFile;
char buffer[BUFSIZE];
DWORD dwBytesWritten;
BOOL fSuccess;
hFile = CreateFile(TEXT("C:\\test.txt"),
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
fSuccess = ReadFile(hFile,
buffer,
strlen(buffer)+1,
&dwBytesWritten,
NULL);
http://msdn2.microsoft.com/en-us/library/aa365467.aspx[^]
When you have all the data in the lpBuffer you can add it to each structure variable.
This is just a suggestion ....
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Programm3r wrote: hFile = CreateFile(TEXT("C:\\test.txt"),
Does this not produce an error for you?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Heh! Leave it to Microsoft to have an API called ReadFile that reads from a file opened for
writing.
Oh wait...maybe that was a typo
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
I did some coding in VC++ to detect a device connected to the PC.
I used the sample coding from this siteitself...
LRESULT CHWDetectDlg::OnMyDeviceChange(WPARAM wParam, LPARAM lParam)
{
....
....
if ( DBT_DEVICEARRIVAL == wParam || DBT_DEVICEREMOVECOMPLETE == wParam ) {
PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lParam;
switch( pHdr->dbch_devicetype ) {
case DBT_DEVTYP_DEVICEINTERFACE:
PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr;
UpdateDevice(pDevInf, wParam);
break;
....
....
}
Here in this code wParam should contain either DBT_DEVICEARRIVAL or
DBT_DEVICEREMOVECOMPLETE ...
But it contains DBT_DEVNODES_CHANGED i.e it is detecting there is some device node changes when any device is inserted or removed..
But i want to know whether it is inserted or removed so that it will go into theloop in the above code...
How to proceed...
Waiting for suggestions..
Regards
vijay
|
|
|
|
|
Hi all,
I Want to Know About
1) Why can't we directly instantiate an Abstract Class, and why we have to create it by its Derived Class only.
2) What is the Difference between an Abstract Class and an Interface in COM.
Please give your suggestions.
Uday kiran
|
|
|
|
|
uday kiran janaswamy wrote: 1) Why can't we directly instantiate an Abstract Class, and why we have to create it by its Derived Class only.
Because that's one of the C++ feature (and it is a very valuable feature: it prevents user to instantiate classes that are not supposed to be instancied). By supplying at least one pure virtual function, your class is abstract:
CMyClass
{
virtual void MyFunc() = 0;
};
uday kiran janaswamy wrote: 2) What is the Difference between an Abstract Class and an Interface in COM.
For me (but I don't know if this is totally true), an abstract class is a class that cannot be instantiated directly (meaning it has at least one pure virtual function). A interface is a "pure abstract class": a class that has only member functions (no member variables) and all of them are pure virtual. In fact this class has no functionality at all, it is just an interface to a class that implements those functionalities.
|
|
|
|
|
Thanks Cedric Moonen you have given a most valuable information about Abstract Class and an Interface.
Uday kiran
|
|
|
|