[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ODBC

Posted on 2006-05-01
12
Medium Priority
?
642 Views
Last Modified: 2008-01-09
Hi..

In my company we often go to control panel and then to administrative tools and we use Data Source (ODBC)
and we select System DSN.

after that we click ADD and we select SQL Server Driver, and we fill all the fields to make the connection between the user computer and the server.

in this example I use windows graphic and clicks to make this configuration.

and my question is:

If there a way that I can do like this example by script or by command... odbcConf.exe or odbcad32.exe , or another command or script..

I just want to make automatic the registration on the data source without going to those icons...and make clicks in to many bottoms..

if any ideas?

thanks..

If I don´t explain well.. please let me know..

Regards

RTL
0
Comment
Question by:Realhawk
  • 6
  • 3
  • 2
11 Comments
 
LVL 19

Expert Comment

by:Rimvis
ID: 16583782
0
 
LVL 4

Expert Comment

by:csachdeva
ID: 16585126
On which application you are working. If you are creating an application in VB then I can provide you code thru which you can configure DSN. If you are going with ASP then I can also provide code thru which you can configure DSN.

So I can tell you exaclty only after your reply.

Regards,
Chetan Sachdeva
0
 

Author Comment

by:Realhawk
ID: 16585925
Rimvis:

I think with this link
Create a DSN to access a SQL Server database with ODBC
http://cwashington.netreach.net/depo/view.asp?Index=388&ScriptType=vbscript
will be useful, let me check with the programming guys..

and I will let you know..


csachdeva:
We have Windows XP and 2000 Pro Clients..

Our ERP is base it in Visual Basic and our database is SQL 2000.

For the guys of technical support is too much doing the same thing... they have to add 35 DSN System for each computer.. and I think is more faster doing by programm ...

if you have any idea.. please let me know...

Thanks

Regards..

RTL
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 4

Expert Comment

by:csachdeva
ID: 16593346
Dear Realhawk,

Ok I have written a code in VB to create a DSN. You can create a DSN with that application. There is no need to move to Windows  application. You wnt to create 35 DSNs so you can  write a code to check whether dsn existed or not if not then create dsn according to that application.

Here I can' send you an attachment of that code. So if possible then send me your email id so that i can send u my code.

Regards,
Chetan Sachdeva
0
 

Author Comment

by:Realhawk
ID: 16597006
ok Chetan..

can you please send me this script, here is my email: <removed by CetusMOD per http:help.jsp#hi99>

Thanks

Roberto Tamez
0
 

Author Comment

by:Realhawk
ID: 16623761
Chetan

I don´t get yet your email.. can you send me please that script.. thanks..

I will wait for your mail...

Regards..

RTL
0
 

Author Comment

by:Realhawk
ID: 16908962
Chetan

I don´t get yet your email.. can you send me please that script.. thanks..  i STILL WAITING...

<removed by CetusMOD per http:help.jsp#hi99>

THANKS

Regards..

RTL
0
 
LVL 19

Expert Comment

by:Rimvis
ID: 16932142
I think I should get the points. The links I provided have enough information on how to create DNS. Check asker's comment on 05/02/2006 04:53PM EEST.
csachdeva offered a complete code, and asker hooked on this. He didn't got it, as I understand. Besides, providing answer via e-mail is against EE rules :)
0
 

Author Comment

by:Realhawk
ID: 16932252
Ok..

Can you provide the code, by copy to this webpage?, to avoid the EE Rules...

'cause is not working the page:
 http://cwashington.netreach.net/depo/view.asp?Index=388&ScriptType=vbscript

neither this link is working
http://www.databasejournal.com/features/mssql/article.php/1477421

Regards

RTL
0
 
LVL 19

Accepted Solution

by:
Rimvis earned 2000 total points
ID: 16934572
I have found a Google copy:

Author: Dixan Martinez

Description:

Create a DSN to access a SQL Server database with ODBC
Script:

'===================
'
' File: CreateDSN.vbs
'
' AUTHOR: Dixan Martinez
' Date : 2/2/2000
'
' COMMENT: Create a DSN to access a SQL Server database with ODBC
'
'===================

   Dim DataSourceName
   Dim DatabaseName
   Dim Description
   Dim DriverPath
   Dim DriverName
   Dim LastUser
   Dim Regional
   Dim Server

   Const SystemFolder= 1
   Dim fso
   Dim SysFolder
   Dim SysFolderPath

   Set fso = wscript.CreateObject("Scripting.FileSystemObject")
   Set SysFolder =fso.GetSpecialFolder(SystemFolder)
   SysFolderPath= SysFolder.Path

   Set oArg= wscript.Arguments

   if oArg.Count <> 4 then
       call Usage
   end if

   'Specify the DSN parameters.

   DataSourceName = oArg(0)
   DatabaseName = oArg(1)
   Description = "Odbc de BD" & DatabaseName
   DriverPath = SysFolderPath & "\sqlsrv32.dll"
   Server = oArg(2)
   LastUser  = oArg(3)

   DriverName = "SQL Server"

   'Creamos objetos que escriben en el registro
        Set WshShell = WScript.CreateObject("WScript.Shell")

    'Establecemos el Key del DSn en el registro
    Dim RegEdPath
    RegEdPath= "HKLM\SOFTWARE\ODBC\ODBC.INI\" & DataSourceName & "\"
    'Grabamos
    WshShell.RegWrite  RegEdPath  , ""

   'Ponemos los valores de la nueva Key correspondiente al DSN

   WshShell.RegWrite  RegEdPath & "Database" , DatabaseName
   WshShell.RegWrite  RegEdPath & "Description" , Description
   WshShell.RegWrite  RegEdPath & "Driver" , DriverPath
   WshShell.RegWrite  RegEdPath & "LastUser" , LastUser
   WshShell.RegWrite  RegEdPath & "Server" , Server

   'Escribo en el Key "ODBC Data Sources" para poder listar el nuevo DSN
   ' en el ODBC Manager

   WshShell.RegWrite "HKLM\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\" & DataSourceName , DriverName

wscript.Quit

'--------------------
Sub Usage
     wscript.echo "Create a DSN to access a SQL Server database with ODBC"
     wscript.echo "Uso :"
     wscript.echo "CreateDSN.vbs <DSNName> <DataBaseName> <SQLServer> <User> "
     wscript.echo ""
     wscript.echo "Ejemplo 1 : CreaDSN.vbs NuevoDSN Pub MySQLServer AdminUser"
     wscript.Quit
end sub
0
 

Author Comment

by:Realhawk
ID: 16936053
Excelent..

Regards

RTL
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question