How to Connect VB6 to SQL2005?
I'm currently doing a library system using VB6 and i want to connect it in SQL2005 for my database, but i don't have any idea how to do it. your Answer will be a great help. Thanks
I'm currently doing a library system using VB6 and i want to connect it in SQL2005 for my database, but i don't have any idea how to do it. your Answer will be a great help. Thanks
Hi Techyman,
I found useful links regarding connecting SQL Server – 2005 database with VB-6. Please check the following links. In this example they explain it steps by steps. Please read the post and get idea. You can do it easily.
· https://msdn.microsoft.com/en-us/library/bb264566(v=sql.90).aspx
· https://itstillworks.com/execute-sql-script-visual-basic-6201818.html
· http://www.itprotoday.com/business-intelligence
· https://stackoverflow.com/questions/2962296/vb6-adodb-connection-string-to-sql-server-2008
Hope this is helpful.
Hi Techyman,
You can try installing a connection line like the following: "Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=test1;Network=DBMSSOCN;Server=100.100.100.100;Integrated Security=SSPI". There are three types of connection: ADO, ODBC, and direct connection type. Each one is different from others. So, choose your connection type according to your need. If you want to learn visually, this video might help you:
Hope this helps.
You’re going to need to enter some code for this one. First, open Visual Basic, create a new project, and specify a location for the project files. Hit “Query” and select “MSHFlexGrid.” Click the blank area in “Form1” to add the MSHFlexGrid to Form1. Here’s where the code comes in. Double click the MSHFlexGrid and enter:
Dim sql_cn As ADODB.Connection
Set sql_cn = New Connection
sql_cn.ConnectionString = “Provider=SQLNCLI.1; Integrated Security=SSPI;” & _
“Persist Security Info=False;” & _
“AttachDBFileName=” & App.Path & “northwnd.mdf;DataSource=server1sqlexpress”
sql_cn.Open
——————-
This code sets up an ADO database connection to northwnd.mdf. The database engine is SQL Server Express. The last thing you need to do is specify data table “orders” as the data source for the MSHFlexGrid. To do this, enter this code:
Dim sql_rs As Recordset
Set sql_rs = New Recordset
sql_rs.Open “Select * from orders”, sql_cn
Set MSHFlexGrid1.DataSource = sql_rs