我有以下代码:
DataTable dt = new DataTable();
dt = Banqqet_detailsbl.selectallrecordfromBooking_details(booking_id);
DataRow dr = ds.Tables["dtBooking_details"].NewRow();
dr["Booking_id"] = booking_id;
dr["booked_by"] = bk_by;
dr["FP_no"] = fp_no;
dr["Name"] = name;
dr["co_name"] = co_name;
dr["Booking_type"] = booking_ty;
dr["occupation"] = occup;
dr["Nationality"] = nationality;
dr["Address"] = address;
dr["email_id"] = email_id;
dr["Pan_no"] = pan_no;
dr["sitting_arrang"] = sitting;
dr["state"] = state;
dr["city"] = city;
dr["pin_code"] = pincode;
dr["Booking_from"] = book_from;
dr["Booking_to"] = book_to;
dr["Venue_type"] = venue;
dr["Type_of_function"] = type_of_func;
dr["Min_people"] = min_assu_pepple;
dr["Expected_people"] = expected_people;
dr["Cost_per_plate"] = cost_per_plate;
dr["Total"] = total;
dr["Av_item"] = av_item;
dr["Av_rate"] = av_rate;
dr["Av_item_total"] = total_av_amount;
dr["Grant_amount"] = grant_amount;
dr["Advance"] = advance;
dr["Due"] = due;
dr["Payment_mode"] = pyment_mode;
dr["card_type"] = card_ty;
dr["Card_no"] = card_no;
ds.Tables["dtBooking_details"].Rows.Add(dr);
ds被宣布为公开
public static DataSet1 ds;
selectallrecordfromBooking_details(booking_id) is a method(i suppose)
,位于Banqqet_detailsbl
public DataTable selectallrecordfromBooking_details(string Booking_id)
{
DataTable dt = new DataTable();
try
{
SqlCommand cmd = new SqlCommand("select * from Booking_details where Booking_id=@Booking_id", con);
cmd.Parameters.AddWithValue("@Booking_id", Booking_id);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(dt);
}
catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
finally {}
return dt;
}
dtBooking_details
是dataset1
DataSet
当我尝试运行代码时,它会给我一个错误:
DataRow dr = ds.Tables["dtBooking_details"].NewRow();
Rrror msg:
使用“New”关键字创建对象实例
在Booking_details数据表中有TableAdapter和Fill,GetData()。
这是错误的原因吗?
我是新手,所以如果我做了些蠢事让我知道我会纠正它。
提前致谢。