473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

VB6 : Create DSN Programatically

neo008
85
Hi all,

Can somebody help me about creation of Data Source Name (DSN) programatically.

I'm using ADO control for connections. MS-Access as database

Thanks

-NEO
Dec 4 '07 #1
1 3963
debasisdas
8,127 Expert 4TB
try to use this

1. add the required ODBC library reference from Project ---> References
2. add 2 listboxes,1 textbox and 1 command button on the form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim ds As New ODBCTool.Dsn
  3. If ls.ListIndex <> -1 Then
  4. If Len(Trim(Text1.Text)) = 0 Then
  5. MsgBox "Enter the name of dns"
  6. End If
  7. tt = ds.CreateDSN(Text1.Text, ls.List(ls.ListIndex), "orcl", "", "debasis", "debasis", "", False, "")
  8. Else
  9. MsgBox "Choose the Driver ..."
  10. End If
  11. End Sub
  12.  
  13. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  14. If KeyCode = 116 Then
  15. Dim ds As New ODBCTool.Dsn
  16. Dim List1() As String
  17. tt = ds.GetOdbcDriverList(List1)
  18. ls1.Clear
  19. tt = ds.GetDataSourceList(List1)
  20. For I = 0 To UBound(List1) - 1
  21. ls1.AddItem List1(I)
  22. Next
  23. ls1.Refresh
  24. End If
  25. End Sub
  26.  
  27.  
  28. Private Sub Form_Load()
  29. Dim ds As New ODBCTool.Dsn
  30. Dim List1() As String
  31. tt = ds.GetOdbcDriverList(List1)
  32.  
  33. For I = 0 To UBound(List1) - 1
  34. ls.AddItem List1(I)
  35. Next
  36.  
  37. tt = ds.GetDataSourceList(List1)
  38. For I = 0 To UBound(List1) - 1
  39. ls1.AddItem List1(I)
  40. Next
  41.  
  42. Command1.Enabled = ls.ListIndex <> -1 And Len(Trim(Text1.Text)) > 0
  43. End Sub
  44.  
  45. Private Sub Text1_Change()
  46. Command1.Enabled = ls.ListIndex <> -1 And Len(Trim(Text1.Text)) > 0
  47. End Sub
  48.  
  49.  
Jan 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Viviana Vc | last post by:
How can I programatically do the equivalent of the following: cacls "C:\Program Files\test" /T /G Everyone:f ? Thanks, Viv
7
by: pintihar | last post by:
Hi, As a follow on from an earlier post I have another question about xslt. Is it possible to create the stylsheet programatically? Is this sensible? In the first phase I needed to map element...
7
by: sea | last post by:
Is it a good idea to programatically create a primary key? For example in a table called names, I have the following fields, (1) firstname (2)lastname (3) ID - will it be ok to create a primary...
1
by: Mike Grishaber | last post by:
Hello All, Does anyone know how to programatically create an ODBC datasource in C#? I want to access some comma separated files using ODBC, and I don't want to go into the configuration...
1
by: Ramón | last post by:
why am I not allowed to intanstiate a new task item? TaskItem task_DC = new TaskItemClass(); This is the erro I get when building: error CS0122:...
0
by: spamfurnace | last post by:
Hi there on this rainy old day, I have some users logging into an asp.net website. The server the site sits on allows users to webmail through a common service/component called Horde. In order...
0
by: Dexter | last post by:
Hello all, I need to create lines in my datagrid programatically. After databinding my datagrid have 5 lines, and programatically i need to create plus 5 white lines. Somebody have a ideia...
3
by: The Woo | last post by:
Can one programatically create a file folder which has the same name as a key field, using a command button? Or, Can there be a a command button which opens up a directory tree to a specified...
1
by: vijay | last post by:
HI ALL, How to create excel chart programatically using C#.net 2005. I have created an excel file by using Gembox.Spreadsheet component.Now i want to add excel Chart to this...
7
by: The Mad Ape | last post by:
Hi I have code to programatically create a label. It works but when I try to call a sub to create a tooltip it does not work. I do not get an error so have no idea what it wrong. Please review...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.