我找不到这种奇怪行为的正确解决方案。在另一个项目中,这就像一个魅力。当我解析 sqlconnection 并使用 System.Data.SqlClient 时,它会在 executereader 下显示这条红色下划线......为什么会这样?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//*********************************
//Definerer connection stringen *
//*********************************
SqlConnection BilleddataBasen = new SqlConnection(WebConfigurationManager.ConnectionStrings["Boligforeningen_AB8"].ConnectionString);
//**************************************
//Definerer de forskellige variabler *
//**************************************
string ImageFilePath = "";
string ImageName = "";
string OverfoereDataTilImageControlPaaAspxSiden = "";
//**************************************************
//Definerer hvordan der skal læses fra databasen *
//**************************************************
SqlCommand SelectBlogIndlæg = new SqlCommand("SELECT FileName, FilePath, OprettelsesDato, Tittel, BilledetsIndhold FROM BillederTilGalleri", BilleddataBasen);
BilleddataBasen.Open();
SqlDataReader reader = BilleddataBasen.ExecuteReader();
while (reader.Read())
{
ImageName += reader["FileName"];
ImageFilePath += reader["FilePath"];
lbl_OprettelsesDato.Text += reader["OprettelsesDato"];
lbl_BilledNavnet.Text += reader["Tittel"];
lbl_BeskrivelseAfBilledet.Text += reader["BilledetsIndhold"];
}
OverfoereDataTilImageControlPaaAspxSiden = ImageFilePath + ImageName;
lbl_BilledFraDataBasen.ImageUrl = OverfoereDataTilImageControlPaaAspxSiden;
//************************************************
//Følgende to linier bestemmer pixel størrelse *
//************************************************
lbl_BilledFraDataBasen.Width = 300;
lbl_BilledFraDataBasen.Height = 250;
//*************************************
//Lukker ned for database tilgangen *
//*************************************
reader.Close();
BilleddataBasen.Close();
}
}