|
-
Feb 19th, 2006, 07:29 PM
#1
Thread Starter
Addicted Member
How I can start application with SQL
I am working with ".mdb" file & DAO successfully (VB6).
But for 2 problem I have to work with SQL I think.
_1. data security
_2. using more PC with same database.
_and also 3. using large database
Now I cannot start programing with SQL(SQL 2000) from VB6.
I need ......
__(1) code to store a data (a row) to SQL database
__(2) code view data (a row) from SQL database
using any Connection method & Provider, what is best for me for Data security & using lan networking.
-
Feb 19th, 2006, 07:56 PM
#2
Re: How I can start application with SQL
Welcome to the forum!
Here's a link showing a connection routine.
You should use ADO with MS SQL.
http://www.vbforums.com/showthread.p...39#post1804439
Also - there are threads at the top of the DB forum here that have tutorials and other info on SQL - but still, feel free to ask!
btw - in our shop we never use Bound controls and always use STORED PROCEDURES...
-
Feb 19th, 2006, 11:51 PM
#3
Re: How I can start application with SQL
 Originally Posted by r_amin
I am working with ".mdb" file & DAO successfully (VB6).
But for 2 problem I have to work with SQL I think.
_1. data security
_2. using more PC with same database.
_and also 3. using large database
Now I cannot start programing with SQL(SQL 2000) from VB6.
I need ......
__(1) code to store a data (a row) to SQL database
__(2) code view data (a row) from SQL database
using any Connection method & Provider, what is best for me for Data security & using lan networking.
If you know how to insert and fetch records using DAO then you would do just fine in SQL since they use the same SQL...
-
Feb 21st, 2006, 01:21 PM
#4
Thread Starter
Addicted Member
Re: How I can start application with SQL
 Originally Posted by dee-u
If you know how to insert and fetch records using DAO then you would do just fine in SQL since they use the same SQL...
you mean, I can use DAO with SQL?
-
Feb 21st, 2006, 01:28 PM
#5
Re: How I can start application with SQL
First - you should remove your e-mail address from your other thread - it will be picked up by bots and you will get spammed!
Second - you should use ADO to connect to MS SQL server. I gave you a link with VB code for a connection - but here it is anyway:
Code:
If strDriver = "" Then
strDriver = "SQLOLEDB"
End If
'Create a connection to the database
Set gCn = New ADODB.Connection
gCn.Provider = strDriver
gCn.Properties("Data Source").Value = strServer
gCn.Properties("Initial Catalog").Value = strDatabase
If gstrUser <> "" Then
gCn.Properties("User Id").Value = gstrUser
gCn.Properties("Password").Value = gstrPassWord
Else
gCn.Properties("Integrated Security").Value = "SSPI"
End If
gCn.CommandTimeout = 300
gCn.Open
'Check the connection state
If gCn.State = adStateOpen Then
EstablishConnection = True
Else
EstablishConnection = False
End If
This will establish a connection to the DB.
Third - use the SEARCH feature of this forum - and search for "GCN" - this is my global connection variable. You will find dozens of threads with all kinds of examples of working with SQL from VB.
-
Feb 21st, 2006, 11:05 PM
#6
Re: How I can start application with SQL
 Originally Posted by r_amin
you mean, I can use DAO with SQL?
No, as Szlamany suggested you should use ADO. What I meant was the DML's, the AddNew, etc are basically the same or with very minimal difference...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|