|
 |
aspx thread: Problem With DataReader
Message #1 by Imtiaz ALAM <imtiaz_alam@u...> on 20 Nov 00 15:43:53 EST
|
|
I am facing problem with the following ASP+ codes. It says Column
ShippingMethod not found. The table and Column exists in the database. I
am
using SQL Server 2000 Evaluation Version.
This code is from "Preview of ASP+", chapter 2
Dim myCommand As SQLCommand
Dim myReader As SQLDataReader
Dim SQL As String
Dim ConnStr As String
SQl =3D "select * from Shipping_Methods"
ConnStr =3D "server=3DDotnet\MyDB;uid=3Dsa;pwd=3D;database=3DAdvWor
ks"
myCommand =3D New SQLCommand(SQL, ConnStr)
myCommand.ActiveConnection.Open()
myCommand.Execute(myReader)
While myReader.Read()
ShipMethod.Items.Add(New ListItem(myReader.Item("ShippingMethod")
, _
myReader.Item
("ShippingMethodID")))
End While
End If
Regards
Imtiaz
Message #2 by "Dave Sussman" <davids@i...> on Tue, 21 Nov 2000 09:03:15 -0000
|
|
This is my fault entirely - I missed out this table from the creation
scripts. The site should be updated soon with correct code, but in the
meantime, just paste this into the SQL Query Analyzer Window on the AdvWorks
database and hit run. It will create the table and add the rows for you.
Dave
CREATE TABLE [dbo].[Shipping_Methods] (
[ShippingMethodID] [int] NOT NULL ,
[ShippingMethod] [nvarchar] (20) NOT NULL
) ON [PRIMARY]
GO
INSERT INTO Shipping_Method(ShippingMethodID, ShippingMethod) VALUES(1,
'Speedy Express')
INSERT INTO Shipping_Method(ShippingMethodID, ShippingMethod) VALUES(2,
'Federal Shipping')
INSERT INTO Shipping_Method(ShippingMethodID, ShippingMethod) VALUES(3,
'Mail Company')
INSERT INTO Shipping_Method(ShippingMethodID, ShippingMethod) VALUES(4,
'Slow Shipping')
GO
"Imtiaz ALAM" <imtiaz_alam@u...> wrote in message news:20594@a...
>
> I am facing problem with the following ASP+ codes. It says Column
> ShippingMethod not found. The table and Column exists in the database. I
> am
> using SQL Server 2000 Evaluation Version.
>
> This code is from "Preview of ASP+", chapter 2
>
> Dim myCommand As SQLCommand
> Dim myReader As SQLDataReader
> Dim SQL As String
> Dim ConnStr As String
>
> SQl =3D "select * from Shipping_Methods"
> ConnStr =3D "server=3DDotnet\MyDB;uid=3Dsa;pwd=3D;database=3DAdvWor
> ks"
>
> myCommand =3D New SQLCommand(SQL, ConnStr)
> myCommand.ActiveConnection.Open()
>
> myCommand.Execute(myReader)
>
> While myReader.Read()
> ShipMethod.Items.Add(New ListItem(myReader.Item("ShippingMethod")
> , _
> myReader.Item
> ("ShippingMethodID")))
> End While
> End If
>
>
> Regards
> Imtiaz
>
>
>
|
|
 |