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
Dealy
NA
213
0
Populate listview with VARBINARY(MAX) variable
Oct 15 2013 2:22 AM
Hello,
I'm trying to populate data from SQL Server into a listview. This is my code in C#:
public void downloadFiles(SqlConnection conn, String sproc, ListView listView, int parentId)
{
SqlCommand command = new SqlCommand(sproc, conn);
command.Parameters.Add(new SqlParameter("@ParentId", parentId));
command.CommandType = CommandType.StoredProcedure;
SqlDataReader rd = null;
conn.Open();
rd = command.ExecuteReader();
while (rd.Read())
{
byte[] b = (byte[])rd["DocPath"];
FileStream fs = new FileStream(rd["DocSubject"].ToString(), FileMode.Create);
fs.Write(b, 0, b.Length);
StreamWriter sw = new StreamWriter(fs);
ListViewItem item = new ListViewItem(rd["ParentId"].ToString());
for (int i = 1; i <= rd.FieldCount - 1; i++)
{
item.SubItems.Add(rd["DocSubject"].ToString());
item.SubItems.Add(rd["DocName"].ToString());
item.SubItems.Add(rd["DocFileFormat"].ToString());
sw.WriteLine(item.SubItems.Add(rd["DocSubject"].ToString()));
sw.Flush();
sw.Close();
}
listView.Items.Add(item);
}
rd.Close();
conn.Close();
}
The problem is that I need DocPath (VARBINARY(MAX) variable) to be populated on column DocPath of the listView as a download link.
I would appreciate any kind of help.
Thank you in advance.
Reply
Answers (
0
)
Enter key navigation in windows form
Play the buzzer continuosly until stopped by the user