August 23, 2010 at 10:30 pm
(added later...Apologies for posting this in the 2005 forum when I'm using 2008. However I'm sure the process is very similar if not exact. Apologies also that it seems to be more VB-centric rather than SQL related but I'm pretty sure my problem is with the SQL Server side of the app and someone here is bound to have experience with this.)
========================
I have followed a very (seemingly) simple example of connecting VB.NET Express to SQL Sever Express.
Both applications reside on the same computer. The database is utterly infantile.. just something for testing (one table with about 6 fields).
I am using Windows Authentication to connect to SQL Express. I have no users defined.
In the VB Application (tiny, skeleton app just to test) I am not specifying a user instance in the connection string. In fact, I have tried many variations of this connections string that does not need a user log-in/password.
Here is my VB Connection code at the moment ( I say "at the moment" because I keep trying different versions with no difference in results)
[Code]
Imports System.Data.SqlClient
Public Class Form1
Dim cs As New SqlConnection("Data Source=.\SQLEXPRESS; Integrated Security=SSPI; Initial Catalog=ADO_TEST")
Dim da As New SqlDataAdapter("SELECT * FROM ADO_TEST.MemberInfo", cs)
Dim ds As New DataSet
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
cs.Open()
MsgBox(cs.State.ToString)
cs.Close()
End Sub
End Class
[/Code]
The above produces a MsgBox that says "Open". So I know the connection is open.
That was just for testing. Now I add something to display my data from the SqlAdapter() method.
I Add a GridControl to my form and name it 'dg' (DataGrid)
I replace the code above (inside the Form1_load Event) with:
[Code]
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Da.Fill(ds, "MemberInfo")
dg.DataSource = ds.Tables("MemberInfo")
End Sub
End Class
[/Code]
Okay, so the problem is that this never returns any result set from the database. The VB Form opens with the dataGrid control but with no results (no headers and no data..just a blank box where the data should be displayed).
Before anyone asks, Yes, the database and table exist and there is just one record in the table and
it's all spelled correctly. I know (well, I *think*) it must have something to do with my connection string and my user instance of SQL Server but I am at a loss as to what to try next.
Do I need to add a user to SQL Sever Express other than the default instance and then pass that login from VB in order for this to work? (again.. see my connection string. I am not using a user instance. I'm *trying* to use the default Windows Authentication).
Thanks for any advice.
-Michael
Viewing post 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy