I have a vb6 .exe which runs a SQL command during an .aspx web service method. It runs well when debugging, but when I run it after hosting in IIS, it shows an error.
This is my code:
System.Diagnostics.ProcessStartInfo ASN_GRN = new System.Diagnostics.ProcessStartInfo();
ASN_GRN.FileName = exePath;
ASN_GRN.WorkingDirectory = basePath;
ASN_GRN.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
ASN_GRN.CreateNoWindow = true;
ASN_GRN.UseShellExecute = false;
ASN_GRN.RedirectStandardOutput = true;
ASN_GRN.RedirectStandardError = true;
if (File.Exists(ASN_GRN.FileName))
{
try
{
using (System.Diagnostics.Process process = System.Diagnostics.Process.Start(ASN_GRN))
{
// This launches the console app
}
}
catch (Exception ex)
{
}
}
When I run it after hosting in IIS, I get this error:
Run-time error '-2147467259 (80004005):
[DBNETLIB] Connection Open [Connect()]. SQL Server does not exists or access denied.
Thanks in advance
I was using MSSQL connection open in my vb6 file
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
cnn.Open strConn 'where the error was thrown as in my question
I migrated to aspx web site and
then I called Process.Start from C# aspx website as per this answer
Process proc = new Process();
proc.StartInfo.FileName = "SAP_to_MSSQL.exe";
proc.WorkingDirectory = @"D:\exepath\";
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Verb = "runas";
proc.Start();
and it runs fine from my IIS-hosted aspx web site. Thanks