473,404 Members | 2,137 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,404 software developers and data experts.

DSNLess Connection: VB 6 + SQL Server 2005

Dököll
2,364 Expert 2GB
Hiya Fans!

I hit a brick wall. I was attempting to make a DSNLess connection I seemed to have Goofed somewhere:

Expand|Select|Wrap|Line Numbers
  1. Private Sub SQLServer_Click()
  2. Dim MyWorkspace As DAO.Workspace
  3. Set MyWorkspace = CreateWorkspace("", "admin", "", dbUseODBC)
  4. Dim MyConnection As DAO.Connection
  5. Set MyConnection = MyWorkspace.OpenConnection("", , , "ODBC;DATABASE=FirstSQLDB")
  6. Dim rec_set As DAO.Recordset
  7. Dim MSSQL As String
  8. MSSQL = "SELECT * FROM Email WHERE EmailAddress ='" & Text1(0).Text & "'"""
  9. Set rec_set = MyWorkspace.OpenRecordset(MSSQL)
  10. Do While Not rec_set.EOF  'this function will keep searching for fields matching each textbox
  11.    'MsgBox ("got here")
  12.         Text1(0).Text = rec_set.fields("EmailAddress")
  13.         Text1(1).Text = rec_set.fields("IPAddress")
  14.         Text1(2).Text = rec_set.fields("DateTimeStamp")
  15.         Text1(3).Text = rec_set.fields("EmailID")       
  16.    rec_set.MoveNext
  17.    Loop
  18.    MyWorkspace.Close
  19.    rec_set.Close
  20.  
  21.  
Trying to grab data out of SQL Server database using DAO with ODBC connection, new to ODBC, have made one fancy connection in the past, forgot it all.

I get a pop up requesting I add DSN name or other...

What do you see?

In a bit!

Dököll
Jan 13 '08 #1
8 4237
Killer42
8,435 Expert 8TB
To be honest, Dököll, I think msquared, NeoPa and the other gurus in the Access forum are likely to be more helpful on this one.
Jan 15 '08 #2
QVeen72
1,445 Expert 1GB
Hi Dököll

ODBC Connection string for DAO is something like this ::

"ODBC;DSN=MYODBCNAME;UID=MYNAME;PWD=MYPASSWORD;DBQ =DATABASENAME;"

Not very sure, if you can connect SQL2005 using DAO in VB6..
use ADO, instead of DAO..

Regards
Veena
Jan 15 '08 #3
Dököll
2,364 Expert 2GB
Hello, Guys!

Funny you mentioned Killer42, got a similar post out there on this and msquared has come to aid, waiting to hear from her on a bit of info I stumbled upon. Thanks for your input. Truth is Veena and msquared are right on target, so thank you also, Veena.

Picked up some books at the library, seem to lead where you're at. Seems to be stearing to ADO instead also. I hope to nail it good with ODBC though:-)

Will tell you what comes out of it...

In a bit guys, thanks!

By the way, Killer42, looks like you got your avatar back. Good!

Dököll
Jan 22 '08 #4
Killer42
8,435 Expert 8TB
Yeah, I figured I would never find the time to update that radar one so went back to something more interesting.
Jan 22 '08 #5
QVeen72
1,445 Expert 1GB
Hi DoKoll,

Try This M$ Example

Regards
Veena
Jan 22 '08 #6
debasisdas
8,127 Expert 4TB
try the use the following sample code

This is for DSN less connection to Oracle using RDO.

Expand|Select|Wrap|Line Numbers
  1. Dim RS As rdoResultset
  2. Dim Cn As rdoConnection
  3. Dim En As rdoEnvironment
  4. Dim Conn As String
  5.  
  6. Private Sub Form_Load()
  7. Set En = rdoEnvironments(0)
  8. Conn = "UID=SCOTT;PWD=TIGER;" _
  9.    & "DATABASE=ORCL;" _
  10.    & "SERVER=ORCL;" _
  11.    & "DRIVER={ORACLE IN ORADB10G_HOME1};DSN='';"
  12. Set Cn = En.OpenConnection(dsName:="", _
  13.    Prompt:=rdDriverNoPrompt, Connect:=Conn)
  14. Set RS = Cn.OpenResultset("SELECT * FROM EMP")
  15. Call DISP
  16. End Sub
  17.  
Jan 22 '08 #7
lotus18
866 512MB
This would be helpful : ). Keep up the good work experts!

Rey Sean
Jan 22 '08 #8
Dököll
2,364 Expert 2GB
This would be helpful : ). Keep up the good work experts!

Rey Sean
Super appreciate it, truly...

Sorry to have been away from this post. I will try your examples. I believe msquared said should be too far from VBA. Will try and see:-)

What outpouring support guys, thanks!!!

Dököll
Jan 28 '08 #9

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

Similar topics

4
by: shank | last post by:
I'm trying to setup an Access DSNLess connection on my local computer. The following string works fine within the Dreamweaver interface. But when I upload to my server (locally) I get this error....
2
by: Tony Epton | last post by:
<crossposted to several groups> Is there any way to create a DSNless connection to SQL server from access 97 (DAO) All the samples of connection strings I am finding - all have a reference to a...
17
by: Danieltbt05 | last post by:
just installed SQL server 2000 and using my client , i can't locate the server. I used SQL query analyzer to search but no servers were found. Error message is as below Server : Msg17,level...
4
by: MrsBean | last post by:
I've been working on learning how to use PHP with MS Access, and as long as I use ODBC, I can make it work. I want to use a DSNless connection. Everthing I have tried has failed. Can anyone show...
16
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with...
3
by: Ted | last post by:
In WSAT, I get the following error when trying to set up my provider: Could not establish a connection to the database. If you have not yet created the SQL Server database, exit the Web Site...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
4
by: matthooper | last post by:
Hello all, I have this peice of code that connects to a SQL server without the DSN Dim cn As ADODB.Connection Dim rs As ADODB.Recordset 'Create a new ADO Connection object...
2
by: samadams_2006 | last post by:
Hello, I have a problem that I'm hoping someone will be able to help me resolve. 1) I have a C# Web Site in which I connect to the database: "Install Microsoft SQL Server 2005 Express...
0
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
Oralloy
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,...
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
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.