Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


VB and SQL Server

Posted on 1999-07-07
Medium Priority
Last Modified: 2010-05-02
    I am running SQL Server as my Database(back end) with Visual Basic as my front end. I am filling the GUI forms which has to store the data that is filled in to SQL server database. also, I want to retrieve the data from the SQL Server database.
I tried to use ADO CONTROL(adodc) But i was unable to connect to the database. Can someone help me with this. i.e. how to connect the SQL Server with the visual basic?????
Question by:kingno1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Accepted Solution

stefie earned 600 total points
ID: 1522453
connect using ODBC

Set MyWorkspace = CreateWorkspace("SQL_SERVER", [loginName], [LoginPassword], dbUseODBC)
Workspaces.Append MyWorkspace

Set dbDatabase = MyWorkspace.OpenDatabase("ARGUS", False, False,"ODBC;DSN=[DSNName];UID=[userID];PWD=[UserPassWord];DATABASE=[DataBaseName])

Change the words between barckets [] with your own settings, identical to your ODBC-settings that are linked to the SQL-DB

Author Comment

ID: 1522454
Hi Stefie,
              Thank you very much for your response. I tried the code that you send me . But, the problem is where to include that code. in the form_load? or in ADODC??
I was unable to catch your point. Also, how to connect the specific fields on the visual basic forms to the Sql server database table fields. Again thanks for ur response.  Anybody, please help me out.
Is DSN means datasource that we set to ODBC?

Expert Comment

ID: 1522455
Put this code where you normally open your database.
The DSN is indeed the DSN in your ODBC, the databasename must also be the same as the one in your ODBC-settings.

Later on, you can do the job on the database (in this example dbDatabase) the same way you do it with DAO. So you can use recordsets or execute SQL-statements (in the form you can put 'em in your SQL-Querytool).


Author Comment

ID: 1522456
Sorry for bothering u again. I tried ur method. But, its giving me the problem.
I will explain everything once. I have GUI visual basic forms and the SQL Server Database. I want to enter or Browse the data into the database which is connected to SQL server. But the problem was I was unable to connect it. I made the settings in ODBC data sourses. But, the ADO control is not working. I have to connect each field in the form to a particular column in the database. But, when I tried to connect the datasource property of the text box.. its noe showing me the browsing symbol, so, I cannt connect that text box to the database.
Can u explain clearly how to do this, Else if u want I can email my program to you.

Thank you very much

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question