|
how can i connect my VC++6 MFC application to sql server? i simply need to know how do i make connection to VC++6 to sql server
|
|
|
|
|
Use this
#define CONNECT_STRING _T("DSN=mmmmmmm;UID=sssssss; PWD=gggggg")
m_pDBConn = new CDatabase();
BOOL w_bIsOpen = FALSE;
if(m_pDBConn)
{
try
{
//opens a connection to the data source
w_bIsOpen = m_pDBConn->OpenEx(CONNECT_STRING);
}
|
|
|
|
|
Hi all,
i m reading a text file by using CStdio file,i want when i redaing the file and find the purticular line now i want to update it.
please tell me how can i do this.
thanks in advance.
|
|
|
|
|
Hi,
The only updates you can do on a text (sequential) file is appending or shortening.
So if you want to change something 'inside' you must create a new file and write there [unchanged beginning][changed part][unchanged ending].
Then you can delete the original file and rename the new file with the original name.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
is there no onther option to update file without deleting old file and create new file.
|
|
|
|
|
Hi,
Le@rner wrote: is there no onther option to update file without deleting old file and create new file
There is no other safe option. If you are adventurous you can
1 Shorten to [unchanged beginning]
2 Append[changed part]
3 Append[unchanged ending]
If a power failure (or like problem) occurs during this processing you may have lost [changed part] and [unchanged ending].
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
In addition to the previous answer: most of the case, when manipulating files, you read them completely in memory and works directly with the data in memory. When you modify the information and have to save your changes, you recreate the complete file at once.
|
|
|
|
|
Another way to do this would be to memory map the file.
This way you can simply modify the contents and they will be automatically saved to disk by the Lazy Writer component of the Windows kernel.
|
|
|
|
|
«_Superman_» wrote: This way you can simply modify the contents
If your changed part is exactly same size as original (may happen)
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
The size can be controlled by mapping more views and using SetEndOfFile .
Happens.
|
|
|
|
|
Don't you think it's slightly overkill for the OP?
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
You're right.
There are so many crazy ways to do things.
|
|
|
|
|
Hey, I just came across a little problem and wanted to ask for your guys opinion.
What would be the most elegant solution to fix this little issue.
if (GetDriveType(drv) == DRIVE_FIXED)
{
GetDiskFreeSpaceEx(drv,0,&DiskSpace,&FreeDiskSpace);
itoa(GetTickCount()/1000%60,ds,10);
itoa(GetTickCount()/1000%60,fs,10);
string temp = "test " + ds + " dasd" + fs;
}
error C2110: '+' : cannot add two pointers
Open for any suggestions, greetings !
|
|
|
|
|
ALLERSLIT wrote: Open for any suggestions, greetings !
You did not show how ds and fs were declared, but one way might be:
string temp = string("test ") + ds + string(" dasd") + fs;
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Does not work out for me.
Getting theese errors:
Does not work out for me.
\test\main.cpp(18) : error C2784: 'std::_String_iterator<_Elem,_Traits,_Alloc> std::operator +(_String_iterator<_Elem,_Traits,_Alloc>::difference_type,std::_String_iterator<_Elem,_Traits,_Alloc>)' : could not deduce template argument for 'std::_String_iterator<_Elem,_Traits,_Alloc>' from 'char [5]'
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(440) : see declaration of 'std::operator +'
\test\main.cpp(18) : error C2784: 'std::_String_const_iterator<_Elem,_Traits,_Alloc> std::operator +(_String_const_iterator<_Elem,_Traits,_Alloc>::difference_type,std::_String_const_iterator<_Elem,_Traits,_Alloc>)' : could not deduce template argument for 'std::_String_const_iterator<_Elem,_Traits,_Alloc>' from 'char [5]'
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(300) : see declaration of 'std::operator +'
\test\main.cpp(18) : error C2784: 'std::reverse_iterator<_RanIt> std::operator +(_Diff,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'char [5]'
1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(2203) : see declaration of 'std::operator +'
\test\main.cpp(18) : error C2784: 'std::_Revranit<_RanIt,_Base> std::operator +(_Diff,const std::_Revranit<_RanIt,_Base> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'char [5]'
1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(2003) : see declaration of 'std::operator +'
\test\main.cpp(18) : error C2676: binary '+' : 'std::basic_string<_Elem,_Traits,_Ax>' does not define this operator or a conversion to a type acceptable to the predefined operator
|
|
|
|
|
string temp = string("test ") + string(ds) + string(" dasd") + string(fs);
|
|
|
|
|
ostringstream os;
os << "test " << ds << " dasd" << fs;
string temp = os.str()
|
|
|
|
|
Hi,
This would do the same without ugly and dangerous multiple additions of std::string and const char* :
#include <sstream>
if (GetDriveType(drv) == DRIVE_FIXED)
{
GetDiskFreeSpaceEx(drv,0,&DiskSpace,&FreeDiskSpace);
std::ostringstream oss;
oss << "test " << GetTickCount() / 1000 % 60;
oss << " dasd " << GetTickCount() / 1000 % 60 << std::ends;
std::string temp = oss.str();
}
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Saturday, October 30, 2010 2:51 AM
|
|
|
|
|
I need to implement a class that offers a client two ways to output data, depending on if they want to display it in ASCII or store it in binary. I figured the best way to implement the ASCII output would be to use a friend function as follows:
friend ostream& operator <<(ostream&, myClass const&); However, to offer a binary output option, I don't know whether I should create a friend function or a class method, and was wondering if there is an accepted best practice in such a scenario. The two options I am considering are:
friend ostream& write(myClass const&);
void write(ostream&) const; If either of these methods (or some other method) is the preferred way of offering such functionality, I would be interested to hear about it.
Similarly, I need to implement the binary input method, for which I have the following three conceivable options:
friend istream& read(myClass&);
void read(ostream&);
static void read(myClass *&, ostream&); Thanks for the help,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
hi all
in neural networks algo of face detection a term is used a lot " training neural network". what does it mean? and a file is used with extension of NNCP which is loaded first. as for as i know that file contains different patterns of faces. i wana implement the neural network algorithm but i don't understand how to train neural network and how to make this NNCp file which contains different face paterens.
any suggestions links will be appreciated.
thanks
|
|
|
|
|
I don't know how many times you plan to ask this question again, but your time would be better spent taking some of the advice that has already been offered. This article[^] has already been suggested as a starting point; try and spend some time learning from it.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi
I already post same question yesterday. I still did not get decent solution for it. I found real cause now. So I post it again here.
The real problem cause:
If I run "VS 2008 debug" and exit my app. Then next time when I tried to build the EXE file, I will get this error. If I don't run debug and just compile the code and link, I will not have this problem.
So I am thinking, VS itself is using it and did not release when I stop debug.
Any ideas?
Best regards,
|
|
|
|
|
transoft wrote: Any ideas?
Does your app have more than one thread?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Before I used it under Windows XP, I never had this problem. Since I moved to Window 7, this type problem keep coming out.
I did not use multi-thread.
Thank you for your reply.
modified on Saturday, October 30, 2010 12:39 AM
|
|
|
|
|
I hope to use a Socket to a Web server to send request, and then obtain Web server respond to my data. But in the response data inside, there is always a response head, how should I get rid of the response head. I tried by the response data length to intercept head off response head data, but I failed, because of different response, data different lengths. How should I do?
#include <stdio.h>
#include <winsock2.h>
#pragma comment(lib,"WS2_32")
void PacketSocket(const char *host,const char *url,const char *data,char *reBuf)
{
wsprintf(reBuf,"POST %s HTTP/1.1\r\nAccept:text/html\r\nAccept-Language:zh-cn,en\r\nAccept-Encoding:gzip,deflate\r\nContent-type:application/x-www-form-urlencoded\r\nAccept-Charset:GBK\r\nHost:%s\r\nContent-Length:%d\r\nContent-Encoding:utf-8\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.3))\r\nConnection:Keep-Alive\r\nSet-Cookie:JSESSIONID=193F85DD5F193A5714CBC5246218ECO3\r\n\r\n%s",url,host,strlen(data),data);
}
int main(){
WSADATA wsa;
WORD version=MAKEWORD(1,1);
if(WSAStartup(version,&wsa)==SOCKET_ERROR){
printf("start error!");
return -1;
}
SOCKET s;
sockaddr_in addr;
s=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(s==INVALID_SOCKET)
{
printf("has a error,the code:%d",GetLastError());
return -1;
}
addr.sin_addr.S_un.S_addr=inet_addr("127.0.0.1");
addr.sin_port=htons(8080);
addr.sin_family=AF_INET;
if(connect(s,(sockaddr*)&addr,sizeof(addr))==SOCKET_ERROR){
printf("connect had an error!");
return -1;
}
char szData[1024];
PacketSocket("localhost","/socket/index.jsp","start=0&limit=15",szData);
if(send(s,szData,strlen(szData),0)==SOCKET_ERROR){
printf("send request had an error!");
return -1;
}
char szRecv[1024];
int nCount=recv(s,szRecv,1024,0);
if(nCount>0)
{
szRecv[nCount]='\0';
printf("%s",szRecv);
}
WSACleanup();
return 0;
}
Response data as follows
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=0910F038DEBB2C62C41C53A4E30C1C00; Path=/socket
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 582
Date: Fri, 29 Oct 2010 14:45:46 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hello,Win32 socket!</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
Receiving request, then this page response to the client
</body>
</html>
Press any key to continue
How do I get from response data removing the following data
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=0910F038DEBB2C62C41C53A4E30C1C00; Path=/socket
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 582
Date: Fri, 29 Oct 2010 14:45:46 GMT
thank you very much!
|
|
|
|
|