Tech
Forums
Jobs
Books
Events
Live
Interviews Prep
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
6
Reply
How to get rid of out of range error?
Resign Designs
May 5 2015 5:57 AM
527
Reply
Hi,
I have this code at page load to and it loads some data from db to form.
try
{
connection.Open();
adapter.SelectCommand = new SqlCommand("select * from mydb order by LangStaticID ASC", connection);
adapter.Fill(ds);
connection.Close();
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
PageTitle.Text = ds.Tables[0].Rows[0].ItemArray[2].ToString();
MetaTitle.Text = ds.Tables[0].Rows[0].ItemArray[3].ToString();
}
when there are no results it gives me this error
How can I handle this error?
tried with this but no luck
if (ds.Tables[0].Rows.Count == 0)
{
//
}
Thanks
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
6
)
Next Recommended Forum
How to implement autocomplete combobox
want to show dynamically images in Crystal report