TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kishore Konatham
NA
63
7.5k
Can not display interface method result data in datagridview
Jul 25 2019 1:57 AM
namespace
WindowsFormsApplication3 {
public
partial
class
MyCarsForm1: {
public
MyCarsForm1() {
InitializeComponent();
cmbSelectCar.Items.Add(
"Auston MartinDB11"
);
}
interface
IDB11 {
void
DB11Specifications();
}
public
class
AustonMartin: MyCarsForm1,
IDB11 {
void
IDB11.DisplaySpecifications() {
DataSet ds =
new
DataSet();
DataTable dt1 =
new
DataTable();
string
c = @
"Data Source=.; Initial Catalog=master; Integrated Security=True"
;
SqlConnection con =
new
SqlConnection(c);
con.Open();
string
query =
"select * from AustonMartinDB11 "
;
SqlCommand cmd =
new
SqlCommand(query, con);
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
da.Fill(ds, query);
dgvSpecifications.DataSource = ds;
}
}
private
void
cmbSelectCar_SelectedIndexChanged(
object
sender, EventArgs e) {
IDB11 am =
new
AustonMartin();
am.DisplaySpecifications();
if
(cmbSelectCar.SelectedIndex == 0) {
am.DisplaySpecifications();
}
}
}
}
// On selecting first index of the combobox, it is displaying empty datagridview.
// On checking by the break point, it is loading the data in the datagridview.
Reply
Answers (
1
)
Try Catch and throw exceptions
How do i reduce loop size using list or linq in C#