|
-
Apr 17th, 2004, 03:54 PM
#1
Thread Starter
Frenzied Member
-
Apr 17th, 2004, 04:06 PM
#2
This is not that experienced of a problem. Its true that the OLEDB data provider in .NET doesn't support ODBC but there is a .NET ODBC Data provider. Just use it instead of OLEDB. If you have VS.NET 2003 then it is built in to the .NET Framework otherwise you have to download it from the Microsoft website.
http://www.microsoft.com/downloads/d...displaylang=en
From there it works just like the SQLClient and OLEDB providers but is for use with ODBC.
-
Apr 18th, 2004, 07:19 AM
#3
Thread Starter
Frenzied Member
thx for the tip,
anyway is it possible to perform what i wanr to do ?>?
can i get the path of the file for the dsn???
this may be very important in building my dbase class
i would appreciate your help
THX
-
Apr 18th, 2004, 12:09 PM
#4
If its a file DSN then you can just open it as text and find the path otherwise I don't know. If you can use the DSN without having the path then why do you need it?
-
Apr 19th, 2004, 04:54 AM
#5
Thread Starter
Frenzied Member
hi there,
i am building a database class that uses oledbconnection to perform tons of common task in my software, i want to make this class as general as possible.
i dont want to declare in it two types of conncetions
(ODBC & OLEDB) and on every operation i should check who will work, i intend to make a single oledb connection that i should use with dsn , by knowing it's name and path.
of course all the databases i intend to connect to is Access 2k , so there will never be a problem with ODBC, as i will always know what is the type of the database behind it.
THX for you attention
BST RGDS
-
Apr 19th, 2004, 05:44 AM
#6
New Member
Help!
I downloaded and installed that package from
http://www.microsoft.com/downloads/d...displaylang=en
but nothing happened. My Visual Studio .NET doesn't understand ODBC. It just says: "Type 'OdbcConnection' is not defined". And naturally it doesn't understand my namespace either.
What's wrong?
-
Apr 19th, 2004, 01:53 PM
#7
Hyperactive Member
Try the following:
Code:
Dim odcQuote As Odbc.OdbcConnection
Dim odaQuote As Odbc.OdbcDataAdapter
That works for me, but I've got .NET 2003
-
Apr 19th, 2004, 02:43 PM
#8
Frenzied Member
or search the registry (were the dsn is stored, extract it, and get ur path to the db from there)
when i opened this thread i thought i would see a question that will take me weeks to figure out,
please from now on title your messages approperiately according to what u need help with, u will get more responses.
-
Apr 20th, 2004, 05:02 AM
#9
New Member
Nothing helps. Or actually I didn't even understand what kovan wrote:
"or search the registry (were the dsn is stored, extract it, and get ur path to the db from there)"
'cause I'm such poor programmer and my english isn't that great either...
I'm just wondering, if it installed into the right place. I didn't change anything in the wizard, so it installed it here:
C:\Program Files\Microsoft.NET\Odbc.Net
it made that Odbc.Net-file. I have also Microsoft Visual Studio .NET -file...
Any ideas?
-
Apr 20th, 2004, 12:31 PM
#10
Frenzied Member
Originally posted by pupil
Nothing helps. Or actually I didn't even understand what kovan wrote:
"or search the registry (were the dsn is stored, extract it, and get ur path to the db from there)"
'cause I'm such poor programmer and my english isn't that great either...
I'm just wondering, if it installed into the right place. I didn't change anything in the wizard, so it installed it here:
C:\Program Files\Microsoft.NET\Odbc.Net
it made that Odbc.Net-file. I have also Microsoft Visual Studio .NET -file...
Any ideas?
lol
all DSN connections one makes through data sources under Administrative Tools in control panel ARE stored in registry
so what has to be done is, one must read the registry and the connection strings and all the properties are stored in registry for each DSN created.
If that doesnt make any sense, then your an idiot.(one or to level lower than a poor programmer)
-
Apr 20th, 2004, 01:31 PM
#11
Fanatic Member
Hi Pupil,
If you need to know details of any of the following steps just ask.
1) Make sure that you have a reference to the System.Data component. If not, then reference it!
2) Open the Object Browser and make sure you can see the System.Data.ODBC namespace. If not, then it is possible that there is a System.Data.ODBC component you need to reference. If there is, then reference it!
3) Where you try to use the odbc objects, try using the fully qualified names (System.Data.ODBC.ODBCConnection).
If none of these help, then I am not sure what the problem might be either.
Kovan , this is a place where people get help. You dont have to put anyone down here, whatever questions they might ask.
-
Apr 21st, 2004, 03:45 AM
#12
New Member
Thanks shunt, but i decided to install Visual Studio 2003 to my computer, so that should solve the problem.
-
Apr 21st, 2004, 06:31 AM
#13
Thread Starter
Frenzied Member
thx kovan, can you explain in .net code how can i extract the dsn properties from the regestry,
i have already sent you a pm , i hope you are not annoyed with my continous questiosn.
thx
-
Apr 21st, 2004, 09:38 AM
#14
Frenzied Member
Originally posted by shunt
Kovan , this is a place where people get help. You dont have to put anyone down here, whatever questions they might ask. [/B]
I dont like being put down when i help someone, they should at least appreciate it,
if they put me down i will put them down.
-
Apr 21st, 2004, 09:55 AM
#15
Frenzied Member
Originally posted by maged
thx kovan, can you explain in .net code how can i extract the dsn properties from the regestry,
i have already sent you a pm , i hope you are not annoyed with my continous questiosn.
thx
Reading registry
VB Code:
Imports Microsoft.Win32
Public Function RegValue(ByVal Hive As RegistryHive, _
ByVal Key As String, ByVal ValueName As String, _
OptionalByRef ErrInfo As String = "") As String
'DEMO USAGE
'Dim sAns As String
'Dim sErr As String = ""
'sAns = RegValue(RegistryHive.LocalMachine, _
' "SOFTWARE\Microsoft\Windows\CurrentVersion", _
' "ProgramFilesDir", sErr)
'If sAns <> "" Then
' Debug.WriteLine("Value = " & sAns)
'Else
' Debug.WriteLine("This error occurred: " & sErr)
'End If
Dim objParent As RegistryKey
Dim objSubkey As RegistryKey
Dim sAns As String
Select Case Hive
Case RegistryHive.ClassesRoot
objParent = Registry.ClassesRoot
Case RegistryHive.CurrentConfig
objParent = Registry.CurrentConfig
Case RegistryHive.CurrentUser
objParent = Registry.CurrentUser
Case RegistryHive.DynData
objParent = Registry.DynData
Case RegistryHive.LocalMachine
objParent = Registry.LocalMachine
Case RegistryHive.PerformanceData
objParent = Registry.PerformanceData
Case RegistryHive.Users
objParent = Registry.Users
End Select
Try
objSubkey = objParent.OpenSubKey(Key)
'if can't be found, object is not initialized
If Not objSubkey Is Nothing Then
sAns = (objSubkey.GetValue(ValueName))
End If
Catch ex As Exception
ErrInfo = ex.Message
Finally
'if no error but value is empty, populate errinfo
If ErrInfo = "" And sAns = "" Then
ErrInfo = _
"No value found for requested registry key"
End If
End Try
Return sAns
End Function
the keys in registry are stored in
HKEY_CURRENT_USER\Software\ODBC\ODBC.INI
as well as
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI
with the above code you have to read these registry values (look through them and find what ur looking for)
it will have all the data.
i would first read a little on reading registry in .NET before going further because you will need to know basics of registry reading if u havent done it before like you mentioned in your PM
hope that helps, if you have any other questions, just post them
-
Apr 24th, 2004, 07:26 AM
#16
Thread Starter
Frenzied Member
thx a million kovan, i will give it a try by myself.
of course i will let you know the results.
Again thank you very much for your kind help
BST RGDS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|