I am attempting to open a connection to a SQL 2000 Server in VB 2005 Express, and I am receiving an InvalidOperationException. I can't seem to figure it out as my VB.NET is a little weak...
Here's the code:
Dim con As New OleDb.OleDbConnection("PROVIDER=SQLOLEDB; packet size=4096;user id=BLAH;data source=SOMESERVER;persist security info=False;database=BooBoo")Dim cmd As New OleDb.OleDbCommand("Select Customer.CustomerID as vCustomerID, Customer.FirstName as vCustomerFirstName, Customer.LastName as vCustomerLastName, Customer.CompanyIDNum as vCompanyIDNum, Customer.Zip as vCustomerZip, Installation.InstallationID as vInstallationID, Installation.Status as vInstallationStatus, Installation.RecieveSignalLevel as vInstallationRSL, Installation.HWType as vInstallationHW from Customer INNER JOIN Installation ON Customer.CustomerID = Installation.CustomerID Where Installation.Status = 'pending'") Dim reader As OleDb.OleDbDataReader = cmd.ExecuteReader() If reader.Read() Then
vpCustomerID = reader(
"vCustomerID").ToStringvpCustomerFirstName = reader(
"vCustomerFirstName").ToStringvpCustomerLastName = reader(
"vCustomerLastName").ToStringvpCustomerCompanyID = reader(
"vCompanyIDNum").ToStringvpCustomerZip = reader(
"vCustomerZip").ToStringvpInstallationID = reader(
"vInstallationID").ToStringvpInstallationStatus = reader(
"vInstallationStatus").ToStringvpInstallationRSL = reader(
"vInstallationRSL").ToStringvpInstallationHWType = reader(
"vInstallationHW").ToStringEnd If
any help would be greatly appreciated!
Jeremy

Newbie Question (kinda)
SanJain
You can better use SQL Client namespace for connecting to SQL
I think that one of your values maybe DBNull.Value. Can you post the query result
You can also place a breakpoint the first line of your routine and see wich line of code generates the error.
KLC
use :
Dim cmd As New OleDb.OleDbCommand("Select Customer.CustomerID as vCustomerID, Customer.FirstName as vCustomerFirstName, Customer.LastName as vCustomerLastName, Customer.CompanyIDNum as vCompanyIDNum, Customer.Zip as vCustomerZip, Installation.InstallationID as vInstallationID, Installation.Status as vInstallationStatus, Installation.RecieveSignalLevel as vInstallationRSL, Installation.HWType as vInstallationHW from Customer INNER JOIN Installation ON Customer.CustomerID = Installation.CustomerID Where Installation.Status = 'pending'", conn)
Wenbin Zhang
tseiy
Ben Ogle
The quey works appropriately in Query Analayzer and produces the intended result.
I placed con.Open() above the read. I am still getting the same error.
InvalidOperationsException. ExecuteReader: Connection property has not been initialized.
J