I just started trying out VB 2005 Express, i'm trying to connect to a SQL 2000 server, is that possible I'm only seeing options for SQL 2005 or Access Any help would be great..
I received an answer in another forum which I'm copying here....
Add a DataGridView control to the form. Once the DataTable is created code:
DataGridView1.DataSource = MyTable
There are lots of better examples in my book.
-- ____________________________________ William (Bill) Vaughn Author, Mentor, Consultant Microsoft MVP INETA Speaker www.betav.com/blog/billva www.betav.com Please reply only to the newsgroup so that others can benefit. This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________ Visit www.hitchhikerguides.net to get more information on my latest book: Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook) -----------------------------------------------------------------------------------------------------------------------
One thing I haven't been able to figure out is how to get the results of a sql server 2000 query into a datagridview. Putting the results in a messagebox isn't really that useful.
I'm trying to create a reporting application that will let the user run some queries and have the results show up in datagridview.
If I am not mistaken the VB Express is limited to local instances.
So if your problem is that you are not being able to connect to a SQLServer. Are you using VB.Net Express and your SQL Instance is remote If so, the express IDE could not connect to a remote instance of SQLServer. It can only connect to a local installation.
"1.3.13 SQL Server Express is the only version of SQL Server that will work with Express Editions other than Visual Web Developer Express Edition.
SQL Server Express is the only version of SQL Server that will work with Visual Basic 2005 Express Edition, Visual C++ 2005 Express Edition, Visual C# 2005 Express Edition, and Visual J# 2005 Express Edition."
VB 2005 Express & SQL Server 2000
Raheel
I received an answer in another forum which I'm copying here....
Add a DataGridView control to the form.
Once the DataTable is created code:
DataGridView1.DataSource = MyTable
There are lots of better examples in my book.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
GarethD25
You just can't use the wizards. They make it difficult. You have to write all the code. Here's how I did it.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strConn, strSQL As String
strConn =
"data source=YourServerName;" & _ "database=YourDatabaseName;Trusted_Connection=yes;"strSQL =
"SELECT Count(*) from [TableName]" Using cn As New SqlConnection(strConn) Trycn.Open()
Catch ex As ExceptionMessageBox.Show(
"Connect Attempt Failed")MessageBox.Show(ex.Message.ToString)
End Try Using cmd As New SqlCommand(strSQL, cn) Try Using rdr As SqlDataReader = cmd.ExecuteReader() Do While rdr.Read()MessageBox.Show(
"SELECT Count(*) from [TableName]" & vbCrLf & vbCrLf & rdr(0), "ADO.Net SQL Test") Looprdr.Close()
End Using Catch ex As SqlExceptionMessageBox.Show(
"Query failed")MessageBox.Show(ex.Message.ToString)
Return End Try End Usingcn.Close()
End Using End SubEnd
ClassZcat
One thing I haven't been able to figure out is how to get the results of a sql server 2000 query into a datagridview. Putting the results in a messagebox isn't really that useful.
I'm trying to create a reporting application that will let the user run some queries and have the results show up in datagridview.
thanks,
Billy
MeOw
If I am not mistaken the VB Express is limited to local instances.
So if your problem is that you are not being able to connect to a SQLServer. Are you using VB.Net Express and your SQL Instance is remote If so, the express IDE could not connect to a remote instance of SQLServer. It can only connect to a local installation.
http://msdn.microsoft.com/vstudio/express/support/readme/#exvb
"1.3.13 SQL Server Express is the only version of SQL Server that will work with Express Editions other than Visual Web Developer Express Edition.
SQL Server Express is the only version of SQL Server that will work with Visual Basic 2005 Express Edition, Visual C++ 2005 Express Edition, Visual C# 2005 Express Edition, and Visual J# 2005 Express Edition."