M
Mat Murdock
I purchased Larry and Dan's cf.net book and I'm having a problem with
the 9-3 example. The example shows you how to connect to a SQL 2000
server and then populate a listbox with some data. When I run it I get
the following error:
An unhandled exception of type 'System.TypeLoadException' occurred in
System.Windows.Forms.dll
I have tried this on three different machines. Two had VS 2003 and one
had VS 2005 beta 2 and I'm getting the same error. Here is my code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cn As System.Data.SqlClient.SqlConnection
Dim cmd As System.Data.SqlClient.SqlCommand
Dim dr As System.Data.SqlClient.SqlDataReader
Try
cn = New System.Data.SqlClient.SqlConnection( _
"user
id=sa;password=xxxxxxx;database=Northwind;server=xxx.xxx.x.x;")
cmd.CommandText = "Select * From Customers"
cmd.Connection = cn
dr = cmd.ExecuteReader
While dr.Read()
ListBox1.Items.Add(dr("CompanyName"))
End While
Catch
Finally
dr.Close()
cn.Close()
End Try
End Sub
I am using SQL server 2000. I can browse the internet on the emulator.
I can login to the sql server with query analyzer using the same
credentials I use on this project. Any help would be most appreciated.
Sorry for the long post,
Mat
the 9-3 example. The example shows you how to connect to a SQL 2000
server and then populate a listbox with some data. When I run it I get
the following error:
An unhandled exception of type 'System.TypeLoadException' occurred in
System.Windows.Forms.dll
I have tried this on three different machines. Two had VS 2003 and one
had VS 2005 beta 2 and I'm getting the same error. Here is my code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cn As System.Data.SqlClient.SqlConnection
Dim cmd As System.Data.SqlClient.SqlCommand
Dim dr As System.Data.SqlClient.SqlDataReader
Try
cn = New System.Data.SqlClient.SqlConnection( _
"user
id=sa;password=xxxxxxx;database=Northwind;server=xxx.xxx.x.x;")
cmd.CommandText = "Select * From Customers"
cmd.Connection = cn
dr = cmd.ExecuteReader
While dr.Read()
ListBox1.Items.Add(dr("CompanyName"))
End While
Catch
Finally
dr.Close()
cn.Close()
End Try
End Sub
I am using SQL server 2000. I can browse the internet on the emulator.
I can login to the sql server with query analyzer using the same
credentials I use on this project. Any help would be most appreciated.
Sorry for the long post,
Mat