textcopy.exe in c++ with CreateProcess

textcopy.exe in c++ with CreateProcess

Post by chri » Fri, 04 Jan 2002 05:07:37



I run the following command in dos and it works fine

C:\mssql7\binn\textcopy.exe /Slocalhost /Uusername /Ppassword
/Ddatabase /Ttable /Ccolumn /W"Where ID='198300' "
/F"C:\Temp\asdfasdf" /I

it works fine in dos then I added it to my c++ applike this

String command="C:\mssql7\binn\textcopy.exe /Slocalhost /Uusername
/Ppassword /Ddatabase /Ttable /Ccolumn /W"Where ID='198300' "
/F"C:\Temp\asdfasdf" /I";

CreateProcess( NULL, command, NULL,NULL,FALSE,0, NULL,NULL,&si,&pi )

The command executes and the sql profiler shows it runs, but No data
is stored when using the C++ version.
Permissions are fine on the dirs allowing all to read just not storing
the data.

the only difference I have found from a sql profiler is that the dos
command line returns this additional line

-- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
timestamp = 0xf6ff14c602000000 with log

Anyone know what could be up? I really thought I had this working, I
can get the data to come out not problem in C++ , but not in?

 
 
 

textcopy.exe in c++ with CreateProcess

Post by Jun Chen[M » Sat, 05 Jan 2002 17:34:32


Hi,

I am not sure what causes the problem, but I am wondering what is reported
in the console. The textcopy program should print some information message
to the console indicating success or not.

I tried the following code, which works fine for me:

#include "stdafx.h"
#include "string.h"
#include "Windows.h"

int main(int argc, char* argv[])
{
        char command[500];
        strcpy(command, "C:\\mssql7\\binn\\textcopy.exe /Ssha-ralphchen-0 /Usa
/P123 /Dnorthwind /Temployees /F\"c:\\testcopy.bmp\" /I /Cphoto /W\"where
EmployeeID=2\"");

    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    // Start the child process.
    if( !CreateProcess( NULL, // No module name (use command line).
        command, // Command line.
        NULL,             // Process handle not inheritable.
        NULL,             // Thread handle not inheritable.
        FALSE,            // Set handle inheritance to FALSE.
        0,                // No creation flags.
        NULL,             // Use parent's environment block.
        NULL,             // Use parent's starting directory.
        &si,              // Pointer to STARTUPINFO structure.
        &pi )             // Pointer to PROCESS_INFORMATION structure.
    )
    {

                MessageBox(NULL, "CreateProcess failed", "Error", MB_OK);
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );

    // Close process and thread handles.
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );

        return 0;

Quote:}

The console shows:

TEXTCOPY Version 1.0
DB-Library version 8.00.194
Data copied into SQL Server image column from file 'c:\testcopy.bmp'.
Press any key to continue

Jun Chen

This posting is provided "AS IS" with no warranties, and confers no rights.

 
 
 

textcopy.exe in c++ with CreateProcess

Post by chri » Sat, 05 Jan 2002 23:56:32


I am trying to do this for a web dll using ISAPI. So there is no console.

It does not report 0 and there are no errors when I run getlastError().

again,

the only difference I have found from a sql profiler is that the dos
command line returns this additional line

-- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
timestamp = 0xf6ff14c602000000 with log

 
 
 

textcopy.exe in c++ with CreateProcess

Post by Gert E.R. Draper » Mon, 07 Jan 2002 07:44:05


Why use CreateProcess if you have the source for textcopy available in the
samples directory of SQL Server. That way you have all the control you want.


Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
? 2001 SQLDev.Net All rights reserved.


Quote:> I am trying to do this for a web dll using ISAPI. So there is no console.

> It does not report 0 and there are no errors when I run getlastError().

> again,

> the only difference I have found from a sql profiler is that the dos
> command line returns this additional line

> -- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
> timestamp = 0xf6ff14c602000000 with log

 
 
 

textcopy.exe in c++ with CreateProcess

Post by chri » Fri, 11 Jan 2002 07:57:58


Well, I really didn't want to reinvent the wheel and I am new to this.
I tried for a while, but I was getting conflicts with my librarys in
the ISAPI.dll that it was a part of. I was looking for a simple way to
do it, but I guess that is not the nature of ISAPI now is it.

Thanks for your help I suppose I will dive back into the textcopy
source and try and make it work.

Can you give me any suggestions about how to solve the problem without
using the dll it would be great.


> Why use CreateProcess if you have the source for textcopy available in the
> samples directory of SQL Server. That way you have all the control you want.


> Please reply only to the newsgroups.
> This posting is provided "AS IS" with no warranties, and confers no rights.
> You assume all risk for your use.
> ? 2001 SQLDev.Net All rights reserved.



> > I am trying to do this for a web dll using ISAPI. So there is no console.

> > It does not report 0 and there are no errors when I run getlastError().

> > again,

> > the only difference I have found from a sql profiler is that the dos
> > command line returns this additional line

> > -- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
> > timestamp = 0xf6ff14c602000000 with log

 
 
 

textcopy.exe in c++ with CreateProcess

Post by Gert E.R. Draper » Sat, 12 Jan 2002 14:23:19


I do not understand what you are asking now. If you want to create an ISAPI
the only option is to create a DLL. What is you problem integrating the
textcopy source into the DLL? You have compile problems or runtime problems?
Textcopy is based on DB-Library which is not something I would want to
include into a ISAPI to begin with, I would use ODBC instead. Because
DB-Library is a dead API, does not support all SQL Server 7.0 and 2000
functionality and data types and ODBC is easier to deal with in a multi
threaded environment which is what you have when you create an ISAPI.


Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
? 2001 SQLDev.Net All rights reserved.


> Well, I really didn't want to reinvent the wheel and I am new to this.
> I tried for a while, but I was getting conflicts with my librarys in
> the ISAPI.dll that it was a part of. I was looking for a simple way to
> do it, but I guess that is not the nature of ISAPI now is it.

> Thanks for your help I suppose I will dive back into the textcopy
> source and try and make it work.

> Can you give me any suggestions about how to solve the problem without
> using the dll it would be great.




> > Why use CreateProcess if you have the source for textcopy available in
the
> > samples directory of SQL Server. That way you have all the control you
want.


> > Please reply only to the newsgroups.
> > This posting is provided "AS IS" with no warranties, and confers no
rights.
> > You assume all risk for your use.
> > ? 2001 SQLDev.Net All rights reserved.



> > > I am trying to do this for a web dll using ISAPI. So there is no
console.

> > > It does not report 0 and there are no errors when I run
getlastError().

> > > again,

> > > the only difference I have found from a sql profiler is that the dos
> > > command line returns this additional line

> > > -- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
> > > timestamp = 0xf6ff14c602000000 with log

 
 
 

textcopy.exe in c++ with CreateProcess

Post by chri » Sun, 13 Jan 2002 01:43:54


SO what you are saying is I should include the textcopy source in my
multithreaded dll?


> I do not understand what you are asking now. If you want to create an ISAPI
> the only option is to create a DLL. What is you problem integrating the
> textcopy source into the DLL? You have compile problems or runtime problems?
> Textcopy is based on DB-Library which is not something I would want to
> include into a ISAPI to begin with, I would use ODBC instead. Because
> DB-Library is a dead API, does not support all SQL Server 7.0 and 2000
> functionality and data types and ODBC is easier to deal with in a multi
> threaded environment which is what you have when you create an ISAPI.


> Please reply only to the newsgroups.
> This posting is provided "AS IS" with no warranties, and confers no rights.
> You assume all risk for your use.
> ? 2001 SQLDev.Net All rights reserved.



> > Well, I really didn't want to reinvent the wheel and I am new to this.
> > I tried for a while, but I was getting conflicts with my librarys in
> > the ISAPI.dll that it was a part of. I was looking for a simple way to
> > do it, but I guess that is not the nature of ISAPI now is it.

> > Thanks for your help I suppose I will dive back into the textcopy
> > source and try and make it work.

> > Can you give me any suggestions about how to solve the problem without
> > using the dll it would be great.



> > > Why use CreateProcess if you have the source for textcopy available in
>  the
> > > samples directory of SQL Server. That way you have all the control you
>  want.


> > > Please reply only to the newsgroups.
> > > This posting is provided "AS IS" with no warranties, and confers no
>  rights.
> > > You assume all risk for your use.
> > > ? 2001 SQLDev.Net All rights reserved.



> > > > I am trying to do this for a web dll using ISAPI. So there is no
>  console.

> > > > It does not report 0 and there are no errors when I run
>  getlastError().

> > > > again,

> > > > the only difference I have found from a sql profiler is that the dos
> > > > command line returns this additional line

> > > > -- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
> > > > timestamp = 0xf6ff14c602000000 with log

 
 
 

textcopy.exe in c++ with CreateProcess

Post by Gert E.R. Draper » Sun, 13 Jan 2002 06:47:00


Why not? Why introduce an other process for each call you make? That is a
Unix approach, NT does not like processes that much and rather deals with
threads.


Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
? 2001 SQLDev.Net All rights reserved.


> SO what you are saying is I should include the textcopy source in my
> multithreaded dll?




> > I do not understand what you are asking now. If you want to create an
ISAPI
> > the only option is to create a DLL. What is you problem integrating the
> > textcopy source into the DLL? You have compile problems or runtime
problems?
> > Textcopy is based on DB-Library which is not something I would want to
> > include into a ISAPI to begin with, I would use ODBC instead. Because
> > DB-Library is a dead API, does not support all SQL Server 7.0 and 2000
> > functionality and data types and ODBC is easier to deal with in a multi
> > threaded environment which is what you have when you create an ISAPI.


> > Please reply only to the newsgroups.
> > This posting is provided "AS IS" with no warranties, and confers no
rights.
> > You assume all risk for your use.
> > ? 2001 SQLDev.Net All rights reserved.



> > > Well, I really didn't want to reinvent the wheel and I am new to this.
> > > I tried for a while, but I was getting conflicts with my librarys in
> > > the ISAPI.dll that it was a part of. I was looking for a simple way to
> > > do it, but I guess that is not the nature of ISAPI now is it.

> > > Thanks for your help I suppose I will dive back into the textcopy
> > > source and try and make it work.

> > > Can you give me any suggestions about how to solve the problem without
> > > using the dll it would be great.



> > > > Why use CreateProcess if you have the source for textcopy available
in
> >  the
> > > > samples directory of SQL Server. That way you have all the control
you
> >  want.


> > > > Please reply only to the newsgroups.
> > > > This posting is provided "AS IS" with no warranties, and confers no
> >  rights.
> > > > You assume all risk for your use.
> > > > ? 2001 SQLDev.Net All rights reserved.



> > > > > I am trying to do this for a web dll using ISAPI. So there is no
> >  console.

> > > > > It does not report 0 and there are no errors when I run
> >  getlastError().

> > > > > again,

> > > > > the only difference I have found from a sql profiler is that the
dos
> > > > > command line returns this additional line

> > > > > -- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
> > > > > timestamp = 0xf6ff14c602000000 with log

 
 
 

textcopy.exe in c++ with CreateProcess

Post by chri » Thu, 17 Jan 2002 03:05:00


Ok I am really a Unix guy so you hit the nail on the head with that
statement.

I am including the example uploadex.dll with textcopy.cpp and I get
errors all around. For some reason it does not like this include from
uploadex:extension.cpp

#include "Extension.h"
#include "MultipartParser.h"
#include <assert.h>
#ifndef ASSERT
#define ASSERT(a)               assert(a)
#endif

with this one in textcopy.cpp

#include <afx.h>                // MFC
#include <iostream.h>           // iostream
#include <stdlib.h>             // C run-time

#if defined (_DEBUG)
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

#define DBNTWIN32               // Win32 DB-Library for Windows NT
#include <sqlfront.h>           // DB-Library
#include <sqldb.h>              // DB-Library

I get the error:

Compiling...
Extension.cpp
C:\Program Files\Microsoft Visual
Studio\VC98\MFC\INCLUDE\afxv_w32.h(14) : fatal error C1189: #error :
WINDOWS.H already included.  MFC apps must not #include <windows.h>
Error executing cl.exe.

any thoughts?


> Why not? Why introduce an other process for each call you make? That is a
> Unix approach, NT does not like processes that much and rather deals with
> threads.


> Please reply only to the newsgroups.
> This posting is provided "AS IS" with no warranties, and confers no rights.
> You assume all risk for your use.
> ? 2001 SQLDev.Net All rights reserved.



> > SO what you are saying is I should include the textcopy source in my
> > multithreaded dll?



> > > I do not understand what you are asking now. If you want to create an
>  ISAPI
> > > the only option is to create a DLL. What is you problem integrating the
> > > textcopy source into the DLL? You have compile problems or runtime
>  problems?
> > > Textcopy is based on DB-Library which is not something I would want to
> > > include into a ISAPI to begin with, I would use ODBC instead. Because
> > > DB-Library is a dead API, does not support all SQL Server 7.0 and 2000
> > > functionality and data types and ODBC is easier to deal with in a multi
> > > threaded environment which is what you have when you create an ISAPI.


> > > Please reply only to the newsgroups.
> > > This posting is provided "AS IS" with no warranties, and confers no
>  rights.
> > > You assume all risk for your use.
> > > ? 2001 SQLDev.Net All rights reserved.



> > > > Well, I really didn't want to reinvent the wheel and I am new to this.
> > > > I tried for a while, but I was getting conflicts with my librarys in
> > > > the ISAPI.dll that it was a part of. I was looking for a simple way to
> > > > do it, but I guess that is not the nature of ISAPI now is it.

> > > > Thanks for your help I suppose I will dive back into the textcopy
> > > > source and try and make it work.

> > > > Can you give me any suggestions about how to solve the problem without
> > > > using the dll it would be great.



> > > > > Why use CreateProcess if you have the source for textcopy available
>  in
>  the
> > > > > samples directory of SQL Server. That way you have all the control
>  you
>  want.


> > > > > Please reply only to the newsgroups.
> > > > > This posting is provided "AS IS" with no warranties, and confers no
>  rights.
> > > > > You assume all risk for your use.
> > > > > ? 2001 SQLDev.Net All rights reserved.



> > > > > > I am trying to do this for a web dll using ISAPI. So there is no
>  console.

> > > > > > It does not report 0 and there are no errors when I run
>  getlastError().

> > > > > > again,

> > > > > > the only difference I have found from a sql profiler is that the
>  dos
> > > > > > command line returns this additional line

> > > > > > -- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
> > > > > > timestamp = 0xf6ff14c602000000 with log

 
 
 

textcopy.exe in c++ with CreateProcess

Post by Mark Koz » Sat, 19 Jan 2002 02:27:23


Double back-slash your file paths.

Escape code your double quotes... \042 if memory serves correctly.

Example:

String command="C:\\mssql7\\binn\\textcopy.exe /Slocalhost /Uusername
/Ppassword /Ddatabase /Ttable /Ccolumn /W \042Where ID='198300'\042 /F
\042C:\Temp\asdfasdf\042 /I";

Something like that.

-Mark


> I run the following command in dos and it works fine

> C:\mssql7\binn\textcopy.exe /Slocalhost /Uusername /Ppassword
> /Ddatabase /Ttable /Ccolumn /W"Where ID='198300' "
> /F"C:\Temp\asdfasdf" /I

> it works fine in dos then I added it to my c++ applike this

> String command="C:\mssql7\binn\textcopy.exe /Slocalhost /Uusername
> /Ppassword /Ddatabase /Ttable /Ccolumn /W"Where ID='198300' "
> /F"C:\Temp\asdfasdf" /I";

> CreateProcess( NULL, command, NULL,NULL,FALSE,0, NULL,NULL,&si,&pi )

> The command executes and the sql profiler shows it runs, but No data
> is stored when using the C++ version.
> Permissions are fine on the dirs allowing all to read just not storing
> the data.

> the only difference I have found from a sql profiler is that the dos
> command line returns this additional line

> -- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
> timestamp = 0xf6ff14c602000000 with log

> Anyone know what could be up? I really thought I had this working, I
> can get the data to come out not problem in C++ , but not in?

 
 
 

1. textcopy via cmd verse in c++ WinExec or CreateProcess

I run the following command in dos and it works fine

C:\mssql7\binn\textcopy.exe /Slocalhost /Uusername /Ppassword
/Ddatabase /Ttable /Ccolumn /W"Where ID='198300' "
/F"C:\Temp\asdfasdf" /I

it works fine in dos then I added it to my c++ applike this

String command="C:\mssql7\binn\textcopy.exe /Slocalhost /Uusername
/Ppassword /Ddatabase /Ttable /Ccolumn /W"Where ID='198300' "
/F"C:\Temp\asdfasdf" /I";

CreateProcess( NULL, command, NULL,NULL,FALSE,0, NULL,NULL,&si,&pi )

The command executes and the sql profiler shows it runs, but No data
is stored when using the C++ version.
Permissions are fine on the dirs allowing all to read just not storing
the data.

the only difference I have found from a sql profiler is that the dos
command line returns this additional line

-- writetext bulk table.column 0xf6ff14c602000000e531000001004a00
timestamp = 0xf6ff14c602000000 with log

Anyone know what could be up? I really thought I had this working, I
can get the data to come out not problem in C++ , but not in?

2. Context-sensitive popups in FMP4

3. textcopy via cmd verse in c++ with CreateProcess or WinExec

4. Query problem

5. Error in .exe if its launched with CreateProcess

6. varchar(255) data truncation from SQL Server 6.5 to 7.0

7. Information on Textcopy.exe

8. ORACLE TUNING SOFTWARE!!!

9. fileimport without textcopy.exe

10. Textcopy.exe

11. textcopy.exe command-line options?

12. help with textcopy.exe

13. My question about "textcopy.exe"