Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 14th, 2007, 09:25 AM
Authorized User
 
Join Date: Oct 2007
Posts: 46
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to debbiecoates
Default dao connection to sql

can anyone point me in the right direction, having spent the past 3 hours looking at this, I am going up the wall.

I am working on a database that someone else has set up. the vb front end is connection to SQL 2000, using a DSN.

its been set up so that the database connection is created once, and from there on other stuff is issued against it.

God knows how the ins and outs work, its a nightmare. the trouble is I am trying to develope 2 new forms unfortunately they wont appear in the database until loads of other stuff has been done, so I was trying to isolate my one page to test it (otherwise its a nightmare opening a vb project with 100+ forms before mine)

so, i have declared a public variable
Public dbGams As DAO.Database


then I open the database, i am not sure if i have this right, I have a DSN on my machine that is pointed to the database which works fine, not sure how to call it.

Public Function dbOpenMain() As Boolean
Set dbGams = OpenDatabase("Gams", dbDriverNoPrompt, False, "ODBC;DSN=Gams;Driver={SQL Server};Server=(Local);Database=txtDatabase;UID=tx tUID;pwd=txtPassword;")
End Function

and this function should allow me to create a recodset by calling

dim rNew as dao.recordset
set rnew = Openrecordset(dbGams, "Select * from Customers")

Public Function OpenRecordset(oDB As Database, ssql As String, Optional bEdit As Boolean = True) As Object
Dim rs As Recordset
Set rs = dbGams.OpenRecordset(ssql, dbOpenDynaset, dbSeeChanges, dbOptimistic)
end function


would be gratefull for any input

 
Old November 14th, 2007, 10:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. this doesn't look bad.. what's your problem??

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using DAO and ADO within ADODB.connection faridrd Access VBA 0 January 8th, 2008 10:43 PM
how to convert this DAO connection code to ADO Con ruth26 VB Databases Basics 0 May 11th, 2006 05:15 AM
Convert ADO connection to DAO database dr_morose Access VBA 0 November 17th, 2004 05:44 PM
Connect query w/ database(dao dsnless connection) omnicap1 Access VBA 0 August 23rd, 2004 01:50 PM
Connect query w/ database(dao dsnless connection) omnicap1 Access VBA 0 August 23rd, 2004 01:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.