473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

get the data from database

in windows form i created four textboxes and picturebox .how can i get the data from the database.

i wrote the code in this manner [ error Cannot find column 3.]

Expand|Select|Wrap|Line Numbers
  1. cmd.Parameters.Clear();
  2.             cmd.CommandText = "Student_select";
  3.             cmd.Parameters.AddWithValue("@sno", textBox1.Text);            
  4.             da = new SqlDataAdapter(cmd);
  5.             ds = new DataSet();
  6.             da.Fill(ds, "Sutdent");
  7.             if (ds.Tables[0].Rows.Count > 0)
  8.             {
  9.                 //textBox1.Text = ds.Tables[0].Rows[0][0].ToString();
  10.                 textBox2.Text = ds.Tables[0].Rows[0][0].ToString();
  11.                 textBox3.Text = ds.Tables[0].Rows[0][1].ToString();
  12.                 textBox4.Text = ds.Tables[0].Rows[0][2].ToString();
  13.  
  14.                 if (ds.Tables[0].Rows [0][3]!= System.DBNull.Value)  // ]there is error ocured
  15.  
  16.                     byte[] data = (byte[])ds.Tables[0].Rows[0][3];
  17.                     ms = new MemoryStream(data);
  18.                     pictureBox1.Image = Image.FromStream(ms);
  19.                 }
  20.                 else
  21.                     pictureBox1.Image = null;
  22.             }
  23.             else
  24.                 MessageBox.Show("not available data");     
  25.  
  26.         }
May 2 '10 #1
3 1284
Monomachus
127 Expert 100+
[ error Cannot find column 3.]
There is no column 3 apparently in your dataset
May 2 '10 #2
tlhintoq
3,525 Expert 2GB
TIP: When you first created your question you were asked to wrap your code with [code] tags.

It really does help a bunch. Look how much easier it is to read now that someone has done it for you. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
May 2 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: srikash | last post by:
Not sure where to post this question as I didn't find any groups specific to enterprise library. So I'm posting here.. I'm trying to retrieve data from a DB2 database. It throws an Invalid...
10
by: MHenry | last post by:
Hi, We were going merrily along for 6 years using this database to record all client checks that came into our office, including information about what the checks were for. Suddenly, network...
5
by: adrin | last post by:
hi, i am writing a program that is supposed to create a database of my music and albums. i want it to consist of 3 'modules' input<->processing<->output. input should enable reading data from cd...
2
by: Jake_adl | last post by:
Is there any way to create a Microsoft.Practices.EnterpriseLibrary.Data.Database object without reading from a configuration file? I am writing a utility that manages databases in SQL Server....
7
by: News | last post by:
Hello, I have to build a program with the future in mind and I need a bit of guidance from a guru or two. My program will start as a multi-user Windows Application built with VB.Net and using an...
5
by: Slant | last post by:
Here's a question that most will have different answers to. I'm just dying to find a solution that seems halfway automated!! There really are two seperate issues which might be answered by the...
3
by: andrewtayloruk | last post by:
I'm a newbie when it come to things php and i'm having a bit of trouble. I'm trying to insert data from an html form into a mysql database and can't get it to work. Just a few bits about my...
8
sumaiya
by: sumaiya | last post by:
I have interactive flash website intelution.com It is getting data from a database using PHP file system print "&photo$i=http://www.intelution.com/$photo&prod$i=$prod&"; The thing is the...
7
by: Jelle de Jong | last post by:
Hi, I want to start a new project, I want to build my own database server and start very simple. I want to create a file-based database server, with XML-files. Does anyone know a good site or...
0
parshupooja
by: parshupooja | last post by:
Hey All, I am trying to create utility to check data inconsistency in ASP.net 2.0 C# means I want to compare two databases in two different sources i.e MS Access and SQL Server. I want to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.