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
George Abdo
NA
1
0
i need help with a reader that is within a dataset
Dec 20 2005 8:17 PM
public OdbcDataReader SelectDataReader(string connString,string Columns,string TableName,string Filters, string OrderBy)
{
OdbcDataReader MyReader;
System.Data.Odbc.OdbcConnection odbcConn = new System.Data.Odbc.OdbcConnection(connString);
string strSQL;
strSQL="SELECT " + Columns + " ";
strSQL+="FROM " + TableName + " ";
if (Filters.Length!=0)
{
strSQL+="WHERE " + Filters + " ";
}
if (OrderBy.Length!=0)
{
if (OrderBy.StartsWith("LIMIT 0,"))
strSQL+=OrderBy + " ";
else
strSQL+="ORDER BY " + OrderBy + " ";
}
System.Data.Odbc.OdbcCommand odbcCommand = new System.Data.Odbc.OdbcCommand(strSQL);
odbcCommand.Connection=odbcConn;
odbcCommand.Connection.Open();
try
{
MyReader=odbcCommand.ExecuteReader();
return MyReader;
}
catch(Exception exc)
{
throw exc;
}
}
this is where i am calling the method
private DataSet CreatePostDataTable(int type)
{
string sRequestID = Request.QueryString["rID"].ToString();
DataSet myDs = new DataSet();
string sSQL = "";
sSQL = " CONCAT('<a class=hyperlinksBlue href=''#'' onclick=window.open(''../default.aspx?tID=',topicID,'&rID=', RequestID,'''',',''myWindow''',',''width=600,height=600,location=no,menubar=no,scrollbars=yes,resizable=yes''',')>',Subject , '</a> <i>',username,'</i> <font color=''#a9a9a9''>',' on ',DATE_FORMAT(createdate, '%m/%d/%Y'),'</font>') as topics ";
myDs = daData.SelectDataODBC(Session["connITRequest"].ToString(),sSQL,"tbltopic","(type='"+type+"') and (requestID="+sRequestID+")","topicID desc");
for (int i =0; i < myDs.Tables[0].Rows.Count; i++)
{
//get the topic ID first.
string sTopicID = myDs.Tables[0].Rows[i][0].ToString();
int Beg=sTopicID.IndexOf("?tID=") + 5 ;
sTopicID=sTopicID.Substring(Beg);
int End=sTopicID.IndexOf("rID=") - 1;
sTopicID=sTopicID.Substring(0,End);
//Find the total number of posts. (Topic (posts) on main page)
MyNewReader= SelectDataReader(Session["connITRequest"].ToString(),"Count(*) as Replies","tblpost","topicID="+sTopicID,"topicID desc");
}
return myDs;
}
i am calling the method above and i need help. as you see i am picking up the id from the dataset and passing it to the method and looping through and calling it according to the dataset. is there a way to move the reader to the next position to add the value again to it. it is only picking up the last values but i need it to add every value to the reader. should i use an array to call or any ideas would help. thanks
here is where i am calling it everytime but i need to store all values but it is storing the last one of course, once the first one is stored i need to move the position to next, any ideas? thanks in advance
MyNewReader= SelectDataReader(Session["connITRequest"].ToString(),"Count(*) as Replies","tblpost","topicID="+sTopicID,"topicID desc");
Reply
Answers (
0
)
How to write an IE plugin?
Data Binding