c#+sql2000的链接问题
using System;using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient ;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
SqlConnection mySqlConnection = new SqlConnection("server=local;database=Northwind;uid=sa;pwd=");
SqlCommand mySqlCommand = mySqlConnection.CreateCommand();
= "SELECT TOP 5 ProductID,ProductName,UnitPrice," + "UnitsInStock,Discontinued" + "FROM Products" + "ORDER BY ProductID";
mySqlConnection.Open();
SqlDataReader productsSqlDataReader = mySqlCommand.ExecuteReader();
int productIDColPos = productsSqlDataReader.GetOrdinal("ProduuctID");
int productNameColPos = productsSqlDataReader.GetOrdinal("ProduuctName");
int unitPriceColPos = productsSqlDataReader.GetOrdinal("UnitPrice");
int unitsInStockColPos = productsSqlDataReader.GetOrdinal("UnitsInStock");
int discontinuedColPos = productsSqlDataReader.GetOrdinal("Discontinued");
while (productsSqlDataReader.Read())
{
Console.WriteLine("ProductID=" + productsSqlDataReader[productIDColPos]);
Console.WriteLine("ProductName=" + productsSqlDataReader[productNameColPos]);
Console.WriteLine("UnitPrice=" + productsSqlDataReader[unitPriceColPos]);
Console.WriteLine("UnitsInStock=" + productsSqlDataReader[unitsInStockColPos]);
Console.WriteLine("Discontinued=" + productsSqlDataReader[discontinuedColPos]);
}
productsSqlDataReader.Close();
mySqlConnection.Close();
Console.ReadKey();
}
}
}
运行时显示红体字部分有问题,为什么啊?请指教啊!谢谢