• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

VB and SQL Server

Hi,
    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?????
thanks,
kingno1
kingno1@hotmail.com
0
kingno1
Asked:
kingno1
  • 2
  • 2
1 Solution
 
stefieCommented:
connect using ODBC

e.g.:
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
0
 
kingno1Author Commented:
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?
0
 
stefieCommented:
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).



0
 
kingno1Author Commented:
ANY ONE PLEASE HELP ME IN SOLVING MY PROBLEM!!!!!!!!!
Hi,
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
kingno1@hotmail.com
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now