PLEASE HELP!!! almost got this working

Mar 25 2007 8:52 PM
i almost got my program working- i can query the database but it only comes up with the information that its set to. for example:
int number = 7; will give me the information for the player with the number 7. int number =86; will give me the info for that player so i know its grabbing from the access database and giving me the information back.

what i want it to do is be able to read the players full name from the text box and grab the information that way. what would be the syntax?help is very very much appreciated.
thanks in advance.

heres all my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.Sql;
using System.Data.OleDb;

namespace WindowsApplication1
{
public partial class SB : Form
{
public SB()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'steelersDataSet.Player' table. You can move, or remove it, as needed.
this.playerTableAdapter.Fill(this.steelersDataSet.Player);

}

private void button1_Click(object sender, EventArgs e)
{

int number = 43;
if (player.Text == "b")
{
pic.Visible = true;
helmet.Visible = true;
pic.Image = Image.FromFile("C:\\Documents and Settings\\Brandi\\Desktop\\Ben.jpg");




this.Cursor = Cursors.WaitCursor;
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Brandi\My Documents\Steelers.mdb");

try
{
conn.Open();
string sSql = "SELECT * FROM player WHERE number=" +number.ToString();

OleDbCommand cmd = new OleDbCommand(sSql, conn);
OleDbDataReader dr = cmd.ExecuteReader();

if (dr.HasRows == true)
{
while (dr.Read())
{
try
{
// assumes dropping values into a textboxes on a form
bio.Text = "Name: " + dr.GetValue(0).ToString() + " " + dr.GetValue(1).ToString() + " \nNumber: " + dr.GetValue(2).ToString() + "\nPosition: " + dr.GetValue(3).ToString() + "\nDate Of Birth: " + dr.GetValue(4).ToString() + " \nExperience: " + dr.GetValue(5).ToString() + " \nCollege:" + dr.GetValue(6).ToString() + " \nHeight: " + dr.GetValue(7).ToString() + " \nWeight:" + dr.GetValue(8).ToString();

}
catch
{
// go on to the next
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString() + " : " + ex.StackTrace.ToString(), "Load Error");
}
finally
{
conn.Close();
this.Cursor = Cursors.Default;
}




}
}

private void clear_Click(object sender, EventArgs e)
{

pic.Visible = false;
player.Clear();
bio.Visible = false;
helmet.Visible = false;
}
}
}

Answers (4)