Click here to Skip to main content
13,046,480 members (71,636 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have four textboxes and one picturebox. i want to bind data from ms sql database to c# windows form and want to rotate with buttons(previous,next,first,last)for it i have done this code so far. all records are properly coming from database and rotating. i have problem only with image. it is not rotating . like all other records i also want to bind image from database and want to rotate like other records with these buttons(Previous,next,first,last).

using System;
using System.Collections.Generndic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;
namespace Picbox_working
public partial class Form1 : Form
SqlConnection con=new SqlConnection("Data Source=SHREY\\SQLEXPRESS;Initial Catalog=MyRecords;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter();
public Form1()
private void Form1_Load(object sender, EventArgs e)
cmd = new SqlCommand("select * from Add_New_Staff", con);
adp = new SqlDataAdapter(cmd);
textBox1.DataBindings.Add("Text", ds.Tables[0], "stid");
textBox2.DataBindings.Add("Text", ds.Tables[0], "sname");
textBox3.DataBindings.Add("Text", ds.Tables[0], "addr");
textBox4.DataBindings.Add("Text", ds.Tables[0], "mobil");
Byte[] data = (Byte[])(ds.Tables[0].Rows[0]["imgdata"]);
MemoryStream mem = new MemoryStream(data);
pictureBox1.Image = Image.FromStream(mem);
private void previous_button_Click(object sender, EventArgs e)
this.BindingContext[ds.Tables[0]].Position -= 1;
private void next_button_Click(object sender, EventArgs e)
this.BindingContext[ds.Tables[0]].Position += 1;
private void first_button_Click(object sender, EventArgs e)
this.BindingContext[ds.Tables[0]].Position = 0; 
private void last_button_Click(object sender, EventArgs e)
this.BindingContext[ds.Tables[0]].Position = this.BindingContext[ds.Tables[0]].Count - 1;
Posted 7-Mar-13 1:45am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 7 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100