|
well the database is already backup to a file. So backup datatbase is a no no.
Select Into returns one row of results, again unrelated to my problem.
What I want is to restore my database froma backup file on a remote machine on LAN.
This is doen by stored procedure using Restore Database blah from disk = path
now if path specifies a computer on LAn then it is like \\servername\drivename$\folder\file.dat
here SQL Server gives up since it does not have access to that drive.
So to provide access i create a temporary share on the said folder using sharing api function netshareadd.
It works fine but Server still cannot access cuz only certain people have rights.
So if i manually right click on the folder and go to security tab and add everyone to the list, SQL Server is happy, since it has access not.
The problem is how to do the same step in code.
Any suggestions???
|
|
|
|
|
So how about the RESTORE DATABASE command?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
That's exactly what doe snot work!
when a RESTORE DATABASE is given a path to file on remote computerr it fails because SQL Server does not have access to the folder!!!
|
|
|
|
|
Sorry, I did not see that (unhighlighted) command mentioned in your second post.
This sounds more like a SQL issue rather than a C++ issue. Do you agree? Have you consulted the microsoft.public.sqlserver.* newsgroups?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I am trying to add a bit map to a cbutton. In the resource editor i do set the bitmap property to true. On the init dialog this is what i have.
CButton* pButton = (CButton*) GetDlgItem(BUTTON_ID);
CBitmap bmp;
bmp.LoadBitmap(BITMAP_ID);
HBITMAP hBmp = HBITMAP(bmp);
pButton->SetBitmap(hBmp);
the bitmap doesnt appear any suggestions? What am i doing wrong???
Thanks in advance
|
|
|
|
|
Try this one.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
thats a subclass and thats what i dont wanna do. I also tried adding the style BS_BITMAP thru the setwindowlong just to makesure the style was being set but no luck.....
|
|
|
|
|
Perhaps bmp is going out of scope and thereby causing badness? Also see my article, FooButton[^].
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
setbitmap takes an object so i dont think that could be a reason. But may be its worth trying.
|
|
|
|
|
sorry ravi, it was a scoping issue but i am still not clear why. the CBitmap bmp; is required to be a class level member. I was assuming that when we call a setbitmap on the button and pass a HBITMAP to it, a copy should be sent and there should be no scoping issue.
|
|
|
|
|
I'm fairly new to MFC and have been tasked with migrating an app from VC++ 6.0 to VC++ 7.0 (vs.net). For those who have done this before, are there any things I should watch out for or know beforehand ?
I was simply going to create a new solution in VS.NET, import my VS6.0 projects into it, and then fix each thing the compiler complains about. Is this the right way to go about it ?
thanks in advance
|
|
|
|
|
I don't think that there is a 'right' way to a v6 to v7 migration. Each project likely has it's own dependancies, libraries, etc. Having said that though, your stated approach would certainly be a good starting point. Although I'd be tempted to have VS7 even create all this stuff for you, by having it open the VS6 project files and see what it does.
Chris Meech
I am Canadian. [heard in a local bar]
Gently arching his fishing rod back he moves the tip forward in a gentle arch releasing the line.... kersplunk [Doug Goulden]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
what I noticed when doing this (VC++6.0 -> 7.0 - 7.2, Studio.NET) was I got a lot of errors with STDIO (generally speaking, and specifically statements that std::ofstream and std::ifstream).
I had a lot of instances where it was ok in 6.0, but when I tried to use IO calls, it needed me to change things to pointers in 7.0 (addresses needed).
my 2 cents...
Johnny
|
|
|
|
|
dvolpe wrote:
was simply going to create a new solution in VS.NET, import my VS6.0 projects into it, and then fix each thing the compiler complains about. Is this the right way to go about it ?
You should be able to just open your existing .dsw in VS7 and it will create the solution for you.
File -> Open Project and then navigate to your .dsw. Maybe take a copy of the 6.0 project folder first before doing it.
I would imagine that you should at least run into some issues with stricter C++ language conformance. So you may have to do a few tweaks. I've not tried it but I can't imagine there will be any major problems.
Kevin
|
|
|
|
|
Hello,
how to install (use) Shockwave Flash ActiveX component and work with him in MS VC++ 6.0 project (fscommand, getVariable, setVariable)?
Thanks!
Serg
|
|
|
|
|
I want to attach a CEdit to A CView,how can i do that,thanks.
just now i've tried another method, i creat a CEditView and use CEditView::GetEditCtrl,which return a reference of CEdit&,but i cannot replace the Standard CEdit to the special CMyEdit derived from that.
help,either way is ok for me now,thanks....
Josephvan thanks for your attention
|
|
|
|
|
CFormView is the only way I know how to do that. That makes it look more like a dialog though, so might not be what you are looking for.
|
|
|
|
|
You can add a CEdit to a CView-derived class (call it CMyView) easily.
In the MyView.h file, add a CEdit member varaible (call it m_ctlEdit).
In the MyView.cpp file, add message handlers for WM_CREATE (i.e., OnCreate) and WM_SIZE (i.e., OnSize). Add code like this:
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct) <br />
{<br />
if (CView::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
DWORD dwStyle = WS_CHILD | WS_VISIBLE;
<br />
if ( !m_ctlEdit.Create( dwStyle, CRect(1,2,3,4), this, 0x1245 ) )<br />
{<br />
return -1;<br />
}<br />
<br />
return 0;<br />
}<br />
<br />
<br />
void CMyView::OnSize(UINT nType, int cx, int cy) <br />
{<br />
CView::OnSize(nType, cx, cy);<br />
<br />
CRect rc;<br />
<br />
GetClientRect( &rc );<br />
<br />
m_ctlEdit.SetWindowPos( this, 0, 0, rc.Width(), rc.Height(), SWP_NOZORDER );<br />
}
This will fill the view with the edit, which might not be what you want, but it's easy to adjust.
Mike
|
|
|
|
|
hi, i am a student and im currently dealing with c++ programming base assignment. however, im not strong in c++ programming language. hope to get help and assiatance. here's my question:
i suppose to write a program that open the serial comm port, configure it and receive data from it. however, the program i wrote is not functioning as it suppose to, as in, it never receives any data. what is wrong with the code. hope to get help. besides, was wondering if anyone has any recommended code that works for me to refer. was really hoping to get help.
the code goes like thia:
#include <windows.h>
#include <stdio.h>
#include <iostream.h>
int main(int argc, char *argv[])
{
DCB cofiguration;
HANDLE hCom;
BOOL fSuccess;
char *pcCommPort = "COM1";
hCom = CreateFile( pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, //share mode: off
NULL,
OPEN_EXISTING, //to open existing file such as port
0,
NULL
);
if (hCom == INVALID_HANDLE_VALUE)
{
cout<<"create file with error ";
cout<<getlasterror(); to="" check="" if="" the="" port="" is="" available
="" return="" (0);
="" }
=""
="" fsuccess="GetCommState(hCom," &cofiguration);
="" cofiguration.baudrate="CBR_9600;"
="" cofiguration.bytesize="8;" cofiguration.parity="NOPARITY;" cofiguration.stopbits="ONESTOPBIT;"
="" &cofiguration);
="" (!fsuccess)="" {
="" cout<<"error="" occur="" "<<endl;
="" cout<<getlasterror();
="" (3);
="" cout<<"port="" opened="" bool="" rdfile;
="" char="" *bufferofdata="" ;
="" unsigned="" long="" nbytesread;
="" int="" sizebuffer="100;
" commtimeouts="" ctmonew="{0}," ctmoold;
="" getcommtimeouts(hcom,&ctmoold);
="" ctmonew.readtotaltimeoutconstant="100;
" ctmonew.readtotaltimeoutmultiplier="0;
" setcommtimeouts(hcom,="" &ctmonew);
="" rdfile="ReadFile(" hcom,bufferofdata,="" sizebuffer,="" &nbytesread,="" null)="" ;="" (="" nbytesread="">0)
{
cout<<"the received word is: ";
}
else if (nBytesRead == 0)
{
cout<<"no input"<
|
|
|
|
|
There is a search bar near the top of this web page. Why not use it and search this site's articles for 'serial port' There are SEVERAL samples already how to open a serial port and read data from it on Windows
|
|
|
|
|
ya, i tried that and i got a sample code that works. but the thing is that the code is way beyond my understanding. i have no idea how it works. besides, someone has tried the code and it works according to him. but i tried with several method and i did not get any positive result. was wondering if there is anyone mind to let me know how do i try the program. thanks a lot. by the way, i'm using Visual C++ 6.
thanks in advance
Rgds
thwan
|
|
|
|
|
Hi all,
Instead of creting the buttons if i drag and drog the buttons and make them ownerdraw on the dialog box and and try to sendthe messages to the background applications the sequence in which the keystroke generate shold be WM_KEYDOWN ->WM_CHAR->WM_KEYUP but its coming as WM_KEYDOWN->WM_KEYUP-> WM_CHAR for me for the following code can any one help me
void MyDialog::GenerateKeyStroke(UINT nVirtualKeyCode)
{
CMainWindow *pView= (CMainWindow*)GetParent();
LPARAM lParam;
lParam = MapVirtualKey(nVirtualKeyCode, 0) ;
//scan code are from 16-23 in lparam
lParam <<= 16;
//since repeat count is one
lParam++;
pView->PostMessage(WM_KEYDOWN , nVirtualKeyCode , lParam ) ;
lParam |= 0xC0000000;
Sleep(0);
pView->PostMessage(WM_KEYUP , nVirtualKeyCode , lParam ) ;
}
and I shold use only PostMessage can any one help adn if press Alt key System keyevents should generate for me what should i do for that
Request to all to continue this
|
|
|
|
|
Does anybody knows how to use dwLastChange field ?
I would like to calc how long my network interface is connected.
Tks
|
|
|
|
|
adriano_alvarez wrote:
Does anybody knows how to use dwLastChange field ?
I believe that member represents the amount of time, in centiseconds, that has elapsed since 1-January-1601.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have installed Platform SDK Windows Server 2003 (I work in VS 6.0 on WinXP) and I have a problem with CFileDialog.
This code
<br />
void CFileTestView::OnViewFile() <br />
{<br />
CFileDialog dlg(TRUE);<br />
dlg.DoModal();<br />
}<br />
worked just fine before defining _WIN32_WINNT, which I need to use different functions and constants. Now, when I define it
<br />
#ifndef _WIN32_WINNT<br />
#define _WIN32_WINNT 0x0501 // can be 0x0500 as well<br />
#endif<br />
my code just crashes in ~CFileDialog (when dlg does out of scope and is destroyed). Since m_ofn member of CFileDialog depends on this _WIN32_WINT:
<br />
typedef struct tagOFN { <br />
#if (_WIN32_WINNT >= 0x0500)<br />
void * pvReserved;<br />
DWORD dwReserved;<br />
DWORD FlagsEx;<br />
#endif // (_WIN32_WINNT >= 0x0500)<br />
} OPENFILENAME<br />
I rewrote the code this way:
<br />
void CFileTestView::OnViewFile() <br />
{<br />
CFileDialog dlg(TRUE);<br />
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
<br />
#if (_WIN32_WINNT >= 0x0500)<br />
dlg.m_ofn.pvReserved = NULL;<br />
dlg.m_ofn.dwReserved = 0;<br />
dlg.m_ofn.FlagsEx = 0;<br />
#endif<br />
<br />
dlg.DoModal();
}<br />
but I still get a first-chance exception in FileTest.Exe (KERNEL32.dll) 0xC0000005: Access Violation (the usual stuff).
Now, I found out that if I declare dlg dinamically it doesn't crash:
<br />
void CFileTestView::OnViewFile() <br />
{<br />
CFileDialog* dlg = new CFileDialog*(TRUE);<br />
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
<br />
#if (_WIN32_WINNT >= 0x0500)<br />
dlg.m_ofn.pvReserved = NULL;<br />
dlg.m_ofn.dwReserved = 0;<br />
dlg.m_ofn.FlagsEx = 0;<br />
#endif<br />
<br />
delete dlg;
}<br />
But If I derive CFileDialog to CMyFileDialog the program still crashes at delete:
<br />
void CFileTestView::OnViewFile() <br />
{<br />
CMyFileDialog* dlg = new CMyFileDialog*(TRUE);<br />
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
<br />
#if (_WIN32_WINNT >= 0x0500)<br />
dlg.m_ofn.pvReserved = NULL;<br />
dlg.m_ofn.dwReserved = 0;<br />
dlg.m_ofn.FlagsEx = 0;<br />
#endif<br />
<br />
delete dlg;
}<br />
Any ideas? Thanks!
|
|
|
|