Hi,
I've been pulling my hair out trying to write a simple method to
programatically create a system DSN with all parameters on a remote machine.
I have ensured I have the correct permissions on that remote machine. I
have also review many MSDN and codeproject.com articles.
Any help would be great.
Thanks,
Derek 8 2821
DerekS wrote: Hi, I've been pulling my hair out trying to write a simple method to programatically create a system DSN with all parameters on a remote machine. I have ensured I have the correct permissions on that remote machine. I have also review many MSDN and codeproject.com articles.
Any help would be great.
Thanks, Derek
It *is* possible to connect without a DSN, or do you have
specific reasons for using it?
Hans Kesting
Yes.. It must be created.
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:OQ**************@TK2MSFTNGP10.phx.gbl... DerekS wrote: Hi, I've been pulling my hair out trying to write a simple method to programatically create a system DSN with all parameters on a remote machine. I have ensured I have the correct permissions on that remote machine. I have also review many MSDN and codeproject.com articles.
Any help would be great.
Thanks, Derek
It *is* possible to connect without a DSN, or do you have specific reasons for using it?
Hans Kesting
Hans,
I assume that you are calling the ConfigDSN function in ODBC.dll (I
think that is the dll)? If so, can you show the declarations, as well as
the call for the function?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"DerekS" <ds********@planview.com> wrote in message
news:eO*************@TK2MSFTNGP14.phx.gbl... Yes.. It must be created.
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message news:OQ**************@TK2MSFTNGP10.phx.gbl... DerekS wrote: > Hi, > I've been pulling my hair out trying to write a simple method to > programatically create a system DSN with all parameters on a remote > machine. I have ensured I have the correct permissions on that remote > machine. I have also review many MSDN and codeproject.com articles. > > Any help would be great. > > Thanks, > Derek
It *is* possible to connect without a DSN, or do you have specific reasons for using it?
Hans Kesting
Hans,
I think I see part of the problem. Your definition for
SQLConfigDataSource should be:
[DllImport("ODBCCP32.DLL", CharSet=CharSet.Ansi)]
static extern bool SQLConfigDataSource(
IntPtr parent,
[MarshalAs(UnmanagedType.U2)
short request,
string driver,
string attributes);
You had request defined as an int, which was shifting the driver and
attributes parmaeters by two bytes.
I've also updated the definition on pinvoke.net, which was incorrect as
well.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
static extern int This function is used to work with the ODBC Datasources
5/20/2004 2:13:16 PM - sh*************@hotmail.com-131.107.3.92
SQLConfigDataSource (int hwndParent, int fRequest, string lpszDriver, string
lpszAttributes);
VB Signature:
"DerekS" <ds********@planview.com> wrote in message
news:uD**************@tk2msftngp13.phx.gbl... I've attached the class.
Here's the basic idea.
I have a simple form that gathers:
Server Name
New DSN Name
I know it SQL Server
I know the server is called 'csgsql2000'
and the user/password is 'ip'/'ip'
I know the remote server the DSN is getting created on is called 'CSAPP13'
See small attached from MSDN
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:ub*************@TK2MSFTNGP14.phx.gbl... Hans,
I assume that you are calling the ConfigDSN function in ODBC.dll (I think that is the dll)? If so, can you show the declarations, as well as the call for the function?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"DerekS" <ds********@planview.com> wrote in message news:eO*************@TK2MSFTNGP14.phx.gbl... > Yes.. It must be created. > > "Hans Kesting" <ne***********@spamgourmet.com> wrote in message > news:OQ**************@TK2MSFTNGP10.phx.gbl... >> DerekS wrote: >> > Hi, >> > I've been pulling my hair out trying to write a simple method to >> > programatically create a system DSN with all parameters on a remote >> > machine. I have ensured I have the correct permissions on that >> > remote >> > machine. I have also review many MSDN and codeproject.com articles. >> > >> > Any help would be great. >> > >> > Thanks, >> > Derek >> >> It *is* possible to connect without a DSN, or do you have >> specific reasons for using it? >> >> Hans Kesting >> >> > >
Great That is getting me closer.... That you SO much. I only have one more
question. I an running this on my local machine however the 'SERVER='
parameter is now correctly showing the correct SQL server, HOWEVER it is
creating this System DSN on my local box. I actually need to remotely
create it on another server that is not the SQL server, and do so from
executing this app from my local box.
Make sense?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl... Hans,
I think I see part of the problem. Your definition for SQLConfigDataSource should be:
[DllImport("ODBCCP32.DLL", CharSet=CharSet.Ansi)] static extern bool SQLConfigDataSource( IntPtr parent, [MarshalAs(UnmanagedType.U2) short request, string driver, string attributes);
You had request defined as an int, which was shifting the driver and attributes parmaeters by two bytes.
I've also updated the definition on pinvoke.net, which was incorrect
as well.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com static extern int This function is used to work with the ODBC Datasources
5/20/2004 2:13:16 PM - sh*************@hotmail.com-131.107.3.92 SQLConfigDataSource (int hwndParent, int fRequest, string lpszDriver,
string lpszAttributes);
VB Signature: "DerekS" <ds********@planview.com> wrote in message news:uD**************@tk2msftngp13.phx.gbl... I've attached the class.
Here's the basic idea.
I have a simple form that gathers:
Server Name
New DSN Name
I know it SQL Server
I know the server is called 'csgsql2000'
and the user/password is 'ip'/'ip'
I know the remote server the DSN is getting created on is called
'CSAPP13' See small attached from MSDN
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:ub*************@TK2MSFTNGP14.phx.gbl... Hans,
I assume that you are calling the ConfigDSN function in ODBC.dll (I think that is the dll)? If so, can you show the declarations, as well
as the call for the function?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"DerekS" <ds********@planview.com> wrote in message news:eO*************@TK2MSFTNGP14.phx.gbl... > Yes.. It must be created. > > "Hans Kesting" <ne***********@spamgourmet.com> wrote in message > news:OQ**************@TK2MSFTNGP10.phx.gbl... >> DerekS wrote: >> > Hi, >> > I've been pulling my hair out trying to write a simple method to >> > programatically create a system DSN with all parameters on a
remote >> > machine. I have ensured I have the correct permissions on that >> > remote >> > machine. I have also review many MSDN and codeproject.com
articles. >> > >> > Any help would be great. >> > >> > Thanks, >> > Derek >> >> It *is* possible to connect without a DSN, or do you have >> specific reasons for using it? >> >> Hans Kesting >> >> > >
Hans,
I don't think that the ODBC APIs allow you to create DSN names on remote
machines. Because of this, you will have to create a service that runs on
the other boxes, which you can connect to through remoting, or COM+, or some
other notification mechanism, and run the code on that box.
I am curious, doesn't AD allow for something like this?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"DerekS" <ds********@planview.com> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl... Great That is getting me closer.... That you SO much. I only have one more question. I an running this on my local machine however the 'SERVER=' parameter is now correctly showing the correct SQL server, HOWEVER it is creating this System DSN on my local box. I actually need to remotely create it on another server that is not the SQL server, and do so from executing this app from my local box.
Make sense?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Hans,
I think I see part of the problem. Your definition for SQLConfigDataSource should be:
[DllImport("ODBCCP32.DLL", CharSet=CharSet.Ansi)] static extern bool SQLConfigDataSource( IntPtr parent, [MarshalAs(UnmanagedType.U2) short request, string driver, string attributes);
You had request defined as an int, which was shifting the driver and attributes parmaeters by two bytes.
I've also updated the definition on pinvoke.net, which was incorrect as well.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com static extern int This function is used to work with the ODBC Datasources
5/20/2004 2:13:16 PM - sh*************@hotmail.com-131.107.3.92 SQLConfigDataSource (int hwndParent, int fRequest, string lpszDriver, string lpszAttributes);
VB Signature: "DerekS" <ds********@planview.com> wrote in message news:uD**************@tk2msftngp13.phx.gbl... > I've attached the class. > > Here's the basic idea. > > I have a simple form that gathers: > > Server Name > > New DSN Name > > I know it SQL Server > > I know the server is called 'csgsql2000' > > and the user/password is 'ip'/'ip' > > I know the remote server the DSN is getting created on is called 'CSAPP13' > > See small attached from MSDN > > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> > wrote > in > message news:ub*************@TK2MSFTNGP14.phx.gbl... >> Hans, >> >> I assume that you are calling the ConfigDSN function in ODBC.dll >> (I >> think that is the dll)? If so, can you show the declarations, as well as >> the call for the function? >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "DerekS" <ds********@planview.com> wrote in message >> news:eO*************@TK2MSFTNGP14.phx.gbl... >> > Yes.. It must be created. >> > >> > "Hans Kesting" <ne***********@spamgourmet.com> wrote in message >> > news:OQ**************@TK2MSFTNGP10.phx.gbl... >> >> DerekS wrote: >> >> > Hi, >> >> > I've been pulling my hair out trying to write a simple method to >> >> > programatically create a system DSN with all parameters on a remote >> >> > machine. I have ensured I have the correct permissions on that >> >> > remote >> >> > machine. I have also review many MSDN and codeproject.com articles. >> >> > >> >> > Any help would be great. >> >> > >> >> > Thanks, >> >> > Derek >> >> >> >> It *is* possible to connect without a DSN, or do you have >> >> specific reasons for using it? >> >> >> >> Hans Kesting >> >> >> >> >> > >> > >> >> > > >
Not Sure...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl... Hans,
I don't think that the ODBC APIs allow you to create DSN names on
remote machines. Because of this, you will have to create a service that runs on the other boxes, which you can connect to through remoting, or COM+, or
some other notification mechanism, and run the code on that box.
I am curious, doesn't AD allow for something like this?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"DerekS" <ds********@planview.com> wrote in message news:OI**************@TK2MSFTNGP12.phx.gbl... Great That is getting me closer.... That you SO much. I only have one more question. I an running this on my local machine however the 'SERVER=' parameter is now correctly showing the correct SQL server, HOWEVER it is creating this System DSN on my local box. I actually need to remotely create it on another server that is not the SQL server, and do so from executing this app from my local box.
Make sense?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Hans,
I think I see part of the problem. Your definition for SQLConfigDataSource should be:
[DllImport("ODBCCP32.DLL", CharSet=CharSet.Ansi)] static extern bool SQLConfigDataSource( IntPtr parent, [MarshalAs(UnmanagedType.U2) short request, string driver, string attributes);
You had request defined as an int, which was shifting the driver
and attributes parmaeters by two bytes.
I've also updated the definition on pinvoke.net, which was
incorrect as well.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com static extern int This function is used to work with the ODBC
Datasources 5/20/2004 2:13:16 PM - sh*************@hotmail.com-131.107.3.92 SQLConfigDataSource (int hwndParent, int fRequest, string lpszDriver, string lpszAttributes);
VB Signature: "DerekS" <ds********@planview.com> wrote in message news:uD**************@tk2msftngp13.phx.gbl... > I've attached the class. > > Here's the basic idea. > > I have a simple form that gathers: > > Server Name > > New DSN Name > > I know it SQL Server > > I know the server is called 'csgsql2000' > > and the user/password is 'ip'/'ip' > > I know the remote server the DSN is getting created on is called 'CSAPP13' > > See small attached from MSDN > > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> > wrote > in > message news:ub*************@TK2MSFTNGP14.phx.gbl... >> Hans, >> >> I assume that you are calling the ConfigDSN function in ODBC.dll >> (I >> think that is the dll)? If so, can you show the declarations, as
well as >> the call for the function? >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "DerekS" <ds********@planview.com> wrote in message >> news:eO*************@TK2MSFTNGP14.phx.gbl... >> > Yes.. It must be created. >> > >> > "Hans Kesting" <ne***********@spamgourmet.com> wrote in message >> > news:OQ**************@TK2MSFTNGP10.phx.gbl... >> >> DerekS wrote: >> >> > Hi, >> >> > I've been pulling my hair out trying to write a simple method
to >> >> > programatically create a system DSN with all parameters on a remote >> >> > machine. I have ensured I have the correct permissions on that >> >> > remote >> >> > machine. I have also review many MSDN and codeproject.com articles. >> >> > >> >> > Any help would be great. >> >> > >> >> > Thanks, >> >> > Derek >> >> >> >> It *is* possible to connect without a DSN, or do you have >> >> specific reasons for using it? >> >> >> >> Hans Kesting >> >> >> >> >> > >> > >> >> > > >
An other approach to this would be to directly edit the registry on the local
machine. Note: This only works for System DSN's.
Here is an example of how to create a SystemDSN for SQL Server:
#using System;
#using Microsoft.Win32
..
..
public class clsODBC
{
private string sDSNName = "";
private string sDB = "";
private string sServer = "";
public clsODBC(string sDSNName, string sDB,string sServer)
{
this.sDSNName = sDSNName;
this.sDB = sDB;
this.sServer = sServer;
}
public bool AddSystemDSN_SQLServer(string sUID, string sPWD)
{
try
{
//create the ODBC Data Source
string sDriver = System.Environment.GetEnvironmentVariable("SystemR oot")
+ @"\System32\SQLSRV32.dll";
RegistryKey oRegKey = Registry.LocalMachine;
oRegKey.OpenSubKey(@"SOFTWARE\ODBC\ODBC.INI",true) .CreateSubKey(sDSNName);
oRegKey.OpenSubKey(@"SOFTWARE\ODBC\ODBC.INI\" +
sDSNName,true).SetValue("Database",sDB);
oRegKey.OpenSubKey(@"SOFTWARE\ODBC\ODBC.INI\" +
sDSNName,true).SetValue("Driver",sDriver);
oRegKey.OpenSubKey(@"SOFTWARE\ODBC\ODBC.INI\" +
sDSNName,true).SetValue("Server",sServer);
if(sUID.Trim() == "*") //if Windows Authentication is used
{
string sLastUser = System.Environment.GetEnvironmentVariable("USERNAM E");
oRegKey.OpenSubKey(@"SOFTWARE\ODBC\ODBC.INI\" +
sDSNName,true).SetValue("Trusted_Connection","Yes" );
oRegKey.OpenSubKey(@"SOFTWARE\ODBC\ODBC.INI\" +
sDSNName,true).SetValue("LastUser",sLastUser);
}
else
{
oRegKey.OpenSubKey(@"SOFTWARE\ODBC\ODBC.INI\" +
sDSNName,true).SetValue("LastUser",sUID);
}
//make the new System DSN visible in the ODBC manager
oRegKey.OpenSubKey(@"SOFTWARE\ODBC\ODBC.INI\ODBC Data
Sources",true).SetValue(sDSNName,"SQL Server");
oRegKey.Close();
return true;
}
catch
{
return false;
}
}
}
"Nicholas Paldino [.NET/C# MVP]" wrote: Hans,
I think I see part of the problem. Your definition for SQLConfigDataSource should be:
[DllImport("ODBCCP32.DLL", CharSet=CharSet.Ansi)] static extern bool SQLConfigDataSource( IntPtr parent, [MarshalAs(UnmanagedType.U2) short request, string driver, string attributes);
You had request defined as an int, which was shifting the driver and attributes parmaeters by two bytes.
I've also updated the definition on pinvoke.net, which was incorrect as well.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com static extern int This function is used to work with the ODBC Datasources
5/20/2004 2:13:16 PM - sh*************@hotmail.com-131.107.3.92 SQLConfigDataSource (int hwndParent, int fRequest, string lpszDriver, string lpszAttributes);
VB Signature: "DerekS" <ds********@planview.com> wrote in message news:uD**************@tk2msftngp13.phx.gbl... I've attached the class.
Here's the basic idea.
I have a simple form that gathers:
Server Name
New DSN Name
I know it SQL Server
I know the server is called 'csgsql2000'
and the user/password is 'ip'/'ip'
I know the remote server the DSN is getting created on is called 'CSAPP13'
See small attached from MSDN
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:ub*************@TK2MSFTNGP14.phx.gbl... Hans,
I assume that you are calling the ConfigDSN function in ODBC.dll (I think that is the dll)? If so, can you show the declarations, as well as the call for the function?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"DerekS" <ds********@planview.com> wrote in message news:eO*************@TK2MSFTNGP14.phx.gbl... > Yes.. It must be created. > > "Hans Kesting" <ne***********@spamgourmet.com> wrote in message > news:OQ**************@TK2MSFTNGP10.phx.gbl... >> DerekS wrote: >> > Hi, >> > I've been pulling my hair out trying to write a simple method to >> > programatically create a system DSN with all parameters on a remote >> > machine. I have ensured I have the correct permissions on that >> > remote >> > machine. I have also review many MSDN and codeproject.com articles. >> > >> > Any help would be great. >> > >> > Thanks, >> > Derek >> >> It *is* possible to connect without a DSN, or do you have >> specific reasons for using it? >> >> Hans Kesting >> >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Prashanth Uppunda |
last post by:
Hello,
Does anybody have an idea on how to instantiate a DCOM
server residing in another machine using C#?
Thanks
Prashanth
|
by: Marc Miller |
last post by:
Hi all,
I have 2 dev. machines, the 1st is Win 2000 with .NET 7.0 and the 2nd is XP
Pro with .NET 2003. My Web Server is Win 2000 Server with IIS 5.0.
I can create a new project on my test...
|
by: David W. Simmonds |
last post by:
I know that I can create an Image object by using a path like
C:\MyPictures\pic.jpg, but how can I create an Image object by using a path
like /MyPictures/pic.jpg where the path is relative to the...
|
by: Peter Afonin |
last post by:
Hello,
I'm using this code to access a network share from an asp.net page:
Dim dir As DirectoryInfo = New DirectoryInfo("\\10.0.0.150\FormLib\")
Dim files() As FileInfo = dir.GetFiles("*.eps")...
|
by: Kent |
last post by:
I am try to link a SQL 2000 table to Access 2000 using VB.Net 2003
Here is my code:
Dim Con As New ADODB.Connection
Dim Cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
...
|
by: purkka |
last post by:
Hi
I replaced a Win 2000 Adv server to the Win 2003 Std with Front Page Server
Extension and .Net Framework 2.0. FPSE is extended to Default Web Site.
Visual Studio 2005: If I create a new web...
|
by: tamayi |
last post by:
I have a problem (like most others posting issues on this forum :) )
I have a remote server running Windows XP SP2, with both SQL Server
2005 Express with Advanced Features and SQL 2000...
|
by: Vlad |
last post by:
I am having problems using the file.create method within a function
that is called when looping through an array of filepaths.
If I call my function with a hardcoded file path --C:\Temp.txt the...
|
by: Kerem Gümrükcü |
last post by:
Hi,
i try to create a remote process with Win32_Process.Create, but the remote
machine always retruns 9 as result, which say that the path could not be
found.
Code seems to be fine, except the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |