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
amna naveed
NA
22
1.2k
hii! I want to retrive data from database into array string
Aug 15 2014 1:49 PM
I want to retrive data from database(mysql) into array string and then want to retrive more data from database based on that array string values. plz help
here is my code
sing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Collections;
public partial class searchresult : System.Web.UI.Page
{
public int i;
public string comment, search,wd;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindParentDataList();
}
}
public void BindParentDataList()
{
ArrayList list = new ArrayList();
SqlCommand cmd1 = new SqlCommand("SELECT * from searches", con);
cmd1.Connection = con;
if (con.State == ConnectionState.Closed)
con.Open();
SqlDataReader rd = cmd1.ExecuteReader();
rd.Read();
list.Add(rd["strings"] + "");
rd.Close();
foreach (string s in list)
{
SqlCommand cmd = new SqlCommand("select * from comment WHERE (CommentOn LIKE \'%" + (s + "%\')"), con);
SqlDataReader myDataReader = cmd.ExecuteReader();
parentDataList.DataSource = myDataReader;
parentDataList.DataBind();
myDataReader.Close();
}
if (con.State == ConnectionState.Open)
con.Close();
i retrive data from table searches and then use the data of searches table to retrive data from comment table. help please
Reply
Answers (
2
)
error object reference not set to an instance of an object
aggregation and composition