이 코드를 실행할 때마다이 오류가 계속 발생하며 실제로 여기에서 누락 된 내용을 찾을 수 없습니다. 미리System.Data.OleDb.OleDbException 'System.Data.dll에서 발생했지만 사용자 코드에서 처리되지 않았습니다.
의 오류 : 'System.Data.OleDb.OleDbException는'가 system.data.dll 발생하지만 사용자 코드
추가 정보 처리되지 않은 조건 식에서 데이터 형식이 일치한다.
프론트 엔드 코드 :
<asp:GridView ID="gvFunction" runat="server" AutoGenerateColumns="false" CssClass="Grid"
DataKeyNames="ID" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<img alt = "" style="cursor: pointer" src="images/plus.png" />
<asp:Panel ID="pnlOrders" runat="server" Style="display: none">
<asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="false" CssClass = "ChildGrid">
<Columns>
<asp:BoundField ItemStyle-Width="150px" DataField="ID" HeaderText="ID" />
<asp:BoundField ItemStyle-Width="150px" DataField="FunctionDate" HeaderText="Function Date" />
<asp:BoundField ItemStyle-Width="150px" DataField="FunctionTime" HeaderText="Function Time" />
<asp:BoundField ItemStyle-Width="150px" DataField="CelebrateName" HeaderText="Celebrate Name" />
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="150px" DataField="ID" HeaderText="ID" />
<asp:BoundField ItemStyle-Width="150px" DataField="FunctionDate" HeaderText="Function Date" />
<asp:BoundField ItemStyle-Width="150px" DataField="CelebrateName" HeaderText="Celebrate Name" />
</Columns>
</asp:GridView>
돌아 가기 종료 코드 :
귀하의 ID 필드를 int 또는 문자열 필드using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.OleDb;
using System.Data;
namespace mntfinal
{
public partial class editreport : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gvFunction.DataSource = GetData("select ID,
FunctionDate, CelebrateName from function");
gvFunction.DataBind();
}
}
private static DataTable GetData(string query)
{
string strConnString = ConfigurationManager.ConnectionStrings
["MandapamDatabase"].ConnectionString;
using (OleDbConnection con = new OleDbConnection(strConnString))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.CommandText = query;
using (OleDbDataAdapter sda = new OleDbDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataSet ds = new DataSet())
{
DataTable dt = new DataTable();
sda.Fill(dt);
return dt;
}
}
}
}
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string ID = gvFunction.DataKeys[e.Row.RowIndex].Value.ToString();
GridView gvOrders = e.Row.FindControl("gvOrders") as GridView;
gvOrders.DataSource = GetData(string.Format("select ID,FunctionDate,FunctionTime,CelebrateName from function where ID='{0}'", ID));
gvOrders.DataBind();
}
}
}
}
내 문제를 해결해 주셔서 고마워요. –