473,395 Members | 1,348 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,395 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 4235
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
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
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
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...
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...

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.