Answered by:
Very Basic ADODB Question

Question
-
Hello all. I am using visual basic 8 express and sql server express.
I found this regarding to visual basic 6, on how to connect to my database, but the connect statments dont work with visual basic 8
Dim cn As ADODB.Connection
Set cn = New Connection
cn.ConnectionString = "Provider=SQLNCLI.1;Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"AttachDBFileName=" & App.Path & "\northwnd.mdf;Data Source=server1\sqlexpress"
cn.Open
Dim rs As Recordset
Set rs = New Recordset
rs.Open "Select * from orders", cn
Set MSHFlexGrid1.DataSource = rsAny ideas?
Thanks alot!
Tuesday, July 8, 2008 6:36 PM
Answers
-
Dim cn = new System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=db_name;")
cn.Open
Dim adapter as System.Data.SqlClient.SqlDataAdapter
Dim rs As New System.Data.DataSetadapter= new System.Data.SqlClient.SqlDataAdapter("Select * from orders", cn)
adapter.fill(rs)
'add code to read rs; it will contain a dataset of the table'db_name is the registered name of the database as seen by SQL Server
hope this helps
Wednesday, July 9, 2008 8:43 PM -
There is a good set of Instructional Videos at
http://msdn.microsoft.com/en-us/vbasic/bb466226.aspx
By: Beth Massi
you can download and watch follow at your own pace.
Wednesday, July 9, 2008 8:51 PM
All replies
-
Dim cn = new System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=db_name;")
cn.Open
Dim adapter as System.Data.SqlClient.SqlDataAdapter
Dim rs As New System.Data.DataSetadapter= new System.Data.SqlClient.SqlDataAdapter("Select * from orders", cn)
adapter.fill(rs)
'add code to read rs; it will contain a dataset of the table'db_name is the registered name of the database as seen by SQL Server
hope this helps
Wednesday, July 9, 2008 8:43 PM -
There is a good set of Instructional Videos at
http://msdn.microsoft.com/en-us/vbasic/bb466226.aspx
By: Beth Massi
you can download and watch follow at your own pace.
Wednesday, July 9, 2008 8:51 PM -
Thank you bothhSaturday, July 12, 2008 2:32 AM