-
retrieve data
private void btnSeek_Click(object sender, EventArgs e)
{
OracleConnection conn = new OracleConnection("user id=1234;data source=FX11;password=1234");
OracleCommand comm = new OracleCommand("SELECT * FROM MYTABLE WHERE EMP_NUMBER = '" + txtSeek.Text + "'");
comm.Connection = conn;
conn.Open();
OracleDataReader dr = comm.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
txtEmpID.Text=dr.GetString(0);
txtLname.text=dr.GetString(1);
txtFname.text=dr.GetString(2);
}
dr.Close();
}
conn.Close();
}
there is a problem on the above codes, can some one help me?
if the user searches for employee's ID, the data will show on txtEmpID, txtLname and txtFname.
in VB6 simply as these:
txtEmpID.Text=rs(0)
txtLname.text=rs(1)
txtFname.text=rs(2)
tnx.
-
Re: retrieve data
Can you explain more whats the problem of the code and what line?
-
Re: retrieve data
just try...
txtEmpID.Text=rs[0]
txtLname.text=rs[1]
txtFname.text=rs[2]
or
txtEmpID.Text=rs["fieldname"]
txtLname.text=rs["fieldname"]
txtFname.text=rs["fieldname"]
-
Re: retrieve data
private void btnSeek_Click(object sender, EventArgs e)
{
OracleConnection conn = new OracleConnection("user id=tscb;data source=FX11;password=tscb");
OracleCommand comm = new OracleCommand("SELECT * FROM TSCBY0001T WHERE EMP_NUMBER = '" + txtSeek.Text + "'");
comm.Connection = conn;
conn.Open();
OracleDataReader dr = comm.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
txtEmpID.Text = dr["EMP_NUMBER"].ToString();
txtLname.Text= dr["LAST_NAME"].ToString();
}
dr.Close();
conn.Close();
}
if you look at the code te red color must execute but when i try to
search the results doesn't show on the text boxes
-
Re: retrieve data
Are you sure the value of the txtSeek is exist in your table. Or else you can debug your project and put a breakpoint in the code that you color red.
-
Re: retrieve data
nope txtseek is not in the table it is a text where u can type the ID u want ti search
-
Re: retrieve data
im not saying that txtseek is in the table, Im saying the value that you inputed in the txtseek textbox.
-
Re: retrieve data
What sort of data does the EMP_NUMBER column contain? Is it text or, as the name would suggest, numbers? You've enclosed the value you're searching for in single quotes so it will be interpreted as text. That can't possibly match any number so your query will return no records.
By the way, thanks for pointing out that it was so easy in VB6. That was very relevant.
-
Re: retrieve data
does anybody already created a database including MSACCESS?
that will ADD,DELETE,EDIT, and SAVE?
if you don't mind could you send ur sample?
tnx to you masters.