Hi guys,
May i know how to match the value in the text box with the table's attribute
in SQL Server? For example, when the customer enter their customer id and
press the button, I want to display out the rows of that customer and not the
whole table. I had done the data binding in the text box with the customer ID
and I don't know whether it is correct or not.
Thanks for ur help..any sample code will be appreciated. 7 1158
Hi!
Well, you might use sql script here.
select value1, value2 from customertable where ID = customerID
To do this you can use a datareader and get the value to the textbox.
/Marre
"alyssa" <al****@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com... Hi guys, May i know how to match the value in the text box with the table's attribute in SQL Server? For example, when the customer enter their customer id and press the button, I want to display out the rows of that customer and not the whole table. I had done the data binding in the text box with the customer ID and I don't know whether it is correct or not. Thanks for ur help..any sample code will be appreciated.
can u explain more? i will appreciate it if u can provide me with a step ny
step instruction..i'm a new beginner here...thanks..
"MA" wrote: Hi!
Well, you might use sql script here. select value1, value2 from customertable where ID = customerID To do this you can use a datareader and get the value to the textbox.
/Marre "alyssa" <al****@discussions.microsoft.com> wrote in message news:48**********************************@microsof t.com... Hi guys, May i know how to match the value in the text box with the table's attribute in SQL Server? For example, when the customer enter their customer id and press the button, I want to display out the rows of that customer and not the whole table. I had done the data binding in the text box with the customer ID and I don't know whether it is correct or not. Thanks for ur help..any sample code will be appreciated.
Ok.
First you have to connect to the sql server:
SqlConnection conn = new SqlConnection(youreConnectionstring);
then you have to run the sql script:
SqlCommand myCommand = new SqlCommand("select value1, value2 from myTable
where ID =" + youreID, conn);
and put it in a datareader:
SqlDataReader myReader = myCommand.ExecuteReader();
To get the text into textboxes you can do like this:
while(myReader.Read())
{
textbox1.Text = myReader["value1"].ToString();
textbox2.Text = myReader["value2"].ToString();
}
"alyssa" <al****@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com... can u explain more? i will appreciate it if u can provide me with a step ny step instruction..i'm a new beginner here...thanks..
"MA" wrote:
Hi!
Well, you might use sql script here. select value1, value2 from customertable where ID = customerID To do this you can use a datareader and get the value to the textbox.
/Marre "alyssa" <al****@discussions.microsoft.com> wrote in message news:48**********************************@microsof t.com... > Hi guys, > May i know how to match the value in the text box with the table's > attribute > in SQL Server? For example, when the customer enter their customer id > and > press the button, I want to display out the rows of that customer and > not > the > whole table. I had done the data binding in the text box with the > customer > ID > and I don't know whether it is correct or not. > Thanks for ur help..any sample code will be appreciated.
what is value1 and value2 mean? is it Customer_ID? and what is myID means?
Do i have to type it in the button? thanks
"MA" wrote: Ok.
First you have to connect to the sql server: SqlConnection conn = new SqlConnection(youreConnectionstring);
then you have to run the sql script: SqlCommand myCommand = new SqlCommand("select value1, value2 from myTable where ID =" + youreID, conn);
and put it in a datareader: SqlDataReader myReader = myCommand.ExecuteReader();
To get the text into textboxes you can do like this:
while(myReader.Read()) { textbox1.Text = myReader["value1"].ToString(); textbox2.Text = myReader["value2"].ToString(); }
"alyssa" <al****@discussions.microsoft.com> wrote in message news:41**********************************@microsof t.com... can u explain more? i will appreciate it if u can provide me with a step ny step instruction..i'm a new beginner here...thanks..
"MA" wrote:
Hi!
Well, you might use sql script here. select value1, value2 from customertable where ID = customerID To do this you can use a datareader and get the value to the textbox.
/Marre "alyssa" <al****@discussions.microsoft.com> wrote in message news:48**********************************@microsof t.com... > Hi guys, > May i know how to match the value in the text box with the table's > attribute > in SQL Server? For example, when the customer enter their customer id > and > press the button, I want to display out the rows of that customer and > not > the > whole table. I had done the data binding in the text box with the > customer > ID > and I don't know whether it is correct or not. > Thanks for ur help..any sample code will be appreciated.
Replace value1 and value2 with the columns from the database table that you
want.
If you have columns called customerName and Customer_ID in a table called
customer, you write:
"select customerName from customer where Customer_ID = "+youreID
where youreID is the ID of the customer (get this from an input field
maybe?).
And you can use this code in the buttons click event.
/Marre
"alyssa" <al****@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com... what is value1 and value2 mean? is it Customer_ID? and what is myID means? Do i have to type it in the button? thanks "MA" wrote:
Ok.
First you have to connect to the sql server: SqlConnection conn = new SqlConnection(youreConnectionstring);
then you have to run the sql script: SqlCommand myCommand = new SqlCommand("select value1, value2 from myTable where ID =" + youreID, conn);
and put it in a datareader: SqlDataReader myReader = myCommand.ExecuteReader();
To get the text into textboxes you can do like this:
while(myReader.Read()) { textbox1.Text = myReader["value1"].ToString(); textbox2.Text = myReader["value2"].ToString(); }
"alyssa" <al****@discussions.microsoft.com> wrote in message news:41**********************************@microsof t.com... > can u explain more? i will appreciate it if u can provide me with a > step > ny > step instruction..i'm a new beginner here...thanks.. > > "MA" wrote: > >> Hi! >> >> Well, you might use sql script here. >> select value1, value2 from customertable where ID = customerID >> To do this you can use a datareader and get the value to the textbox. >> >> /Marre >> "alyssa" <al****@discussions.microsoft.com> wrote in message >> news:48**********************************@microsof t.com... >> > Hi guys, >> > May i know how to match the value in the text box with the table's >> > attribute >> > in SQL Server? For example, when the customer enter their customer >> > id >> > and >> > press the button, I want to display out the rows of that customer >> > and >> > not >> > the >> > whole table. I had done the data binding in the text box with the >> > customer >> > ID >> > and I don't know whether it is correct or not. >> > Thanks for ur help..any sample code will be appreciated. >> >> >>
errmm....this prog works like this...it is a summary report form where
there's a text box calling the user to enter a customer id and click the
button. then, there's a data grid displaying all the particulars about that
customer id only..so i don't understand what's 'yourid' means and how do i
get this from the text box?sorry,i'm a bit slow here...how to display the
result in the data grid?thanks
"MA" wrote: Replace value1 and value2 with the columns from the database table that you want. If you have columns called customerName and Customer_ID in a table called customer, you write: "select customerName from customer where Customer_ID = "+youreID where youreID is the ID of the customer (get this from an input field maybe?).
And you can use this code in the buttons click event.
/Marre "alyssa" <al****@discussions.microsoft.com> wrote in message news:31**********************************@microsof t.com... what is value1 and value2 mean? is it Customer_ID? and what is myID means? Do i have to type it in the button? thanks "MA" wrote:
Ok.
First you have to connect to the sql server: SqlConnection conn = new SqlConnection(youreConnectionstring);
then you have to run the sql script: SqlCommand myCommand = new SqlCommand("select value1, value2 from myTable where ID =" + youreID, conn);
and put it in a datareader: SqlDataReader myReader = myCommand.ExecuteReader();
To get the text into textboxes you can do like this:
while(myReader.Read()) { textbox1.Text = myReader["value1"].ToString(); textbox2.Text = myReader["value2"].ToString(); }
"alyssa" <al****@discussions.microsoft.com> wrote in message news:41**********************************@microsof t.com... > can u explain more? i will appreciate it if u can provide me with a > step > ny > step instruction..i'm a new beginner here...thanks.. > > "MA" wrote: > >> Hi! >> >> Well, you might use sql script here. >> select value1, value2 from customertable where ID = customerID >> To do this you can use a datareader and get the value to the textbox. >> >> /Marre >> "alyssa" <al****@discussions.microsoft.com> wrote in message >> news:48**********************************@microsof t.com... >> > Hi guys, >> > May i know how to match the value in the text box with the table's >> > attribute >> > in SQL Server? For example, when the customer enter their customer >> > id >> > and >> > press the button, I want to display out the rows of that customer >> > and >> > not >> > the >> > whole table. I had done the data binding in the text box with the >> > customer >> > ID >> > and I don't know whether it is correct or not. >> > Thanks for ur help..any sample code will be appreciated. >> >> >>
Well. Youre not slow :)
use this sql string to do it:
"select customerName from customer where Customer_ID = "+textbox.text
Where the textbox is the input field from the customer.
Youre code would look like this if I made it :)
private void button1_Click(object sender, System.EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("col1", typeof(string)));
dt.Columns.Add(new DataColumn("col2", typeof(string)));
SqlConnection conn = new SqlConnection(youreConnectionstring);
conn.Open();
SqlCommand myCommand = new SqlCommand("select value1, value2 from
myTable where ID =" + textbox1.text, conn);
SqlDataReader myReader = myCommand.ExecuteReader();
DataView dv;
DataRow dr;
while(myReader.Read())
{
dr = dt.NewRow();
dr[0] = myReader["value1"].ToString();
dr[1] = myReader["value2"].ToString();
dt.Rows.Add(dr);
}
myReader.Close();
conn.Close();
dv = new DataView(dt);
DataGrid1.DataSource = dv;
DataGrid1.DataBind();
}
/Marre
"alyssa" <al****@discussions.microsoft.com> wrote in message
news:27**********************************@microsof t.com... errmm....this prog works like this...it is a summary report form where there's a text box calling the user to enter a customer id and click the button. then, there's a data grid displaying all the particulars about that customer id only..so i don't understand what's 'yourid' means and how do i get this from the text box?sorry,i'm a bit slow here...how to display the result in the data grid?thanks
"MA" wrote:
Replace value1 and value2 with the columns from the database table that you want. If you have columns called customerName and Customer_ID in a table called customer, you write: "select customerName from customer where Customer_ID = "+youreID where youreID is the ID of the customer (get this from an input field maybe?).
And you can use this code in the buttons click event.
/Marre "alyssa" <al****@discussions.microsoft.com> wrote in message news:31**********************************@microsof t.com... > what is value1 and value2 mean? is it Customer_ID? and what is myID > means? > Do i have to type it in the button? thanks > "MA" wrote: > >> Ok. >> >> First you have to connect to the sql server: >> SqlConnection conn = new SqlConnection(youreConnectionstring); >> >> then you have to run the sql script: >> SqlCommand myCommand = new SqlCommand("select value1, value2 from >> myTable >> where ID =" + youreID, conn); >> >> and put it in a datareader: >> SqlDataReader myReader = myCommand.ExecuteReader(); >> >> To get the text into textboxes you can do like this: >> >> while(myReader.Read()) >> { >> textbox1.Text = myReader["value1"].ToString(); >> textbox2.Text = myReader["value2"].ToString(); >> } >> >> "alyssa" <al****@discussions.microsoft.com> wrote in message >> news:41**********************************@microsof t.com... >> > can u explain more? i will appreciate it if u can provide me with a >> > step >> > ny >> > step instruction..i'm a new beginner here...thanks.. >> > >> > "MA" wrote: >> > >> >> Hi! >> >> >> >> Well, you might use sql script here. >> >> select value1, value2 from customertable where ID = customerID >> >> To do this you can use a datareader and get the value to the >> >> textbox. >> >> >> >> /Marre >> >> "alyssa" <al****@discussions.microsoft.com> wrote in message >> >> news:48**********************************@microsof t.com... >> >> > Hi guys, >> >> > May i know how to match the value in the text box with the >> >> > table's >> >> > attribute >> >> > in SQL Server? For example, when the customer enter their >> >> > customer >> >> > id >> >> > and >> >> > press the button, I want to display out the rows of that customer >> >> > and >> >> > not >> >> > the >> >> > whole table. I had done the data binding in the text box with the >> >> > customer >> >> > ID >> >> > and I don't know whether it is correct or not. >> >> > Thanks for ur help..any sample code will be appreciated. >> >> >> >> >> >> >> >> >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Schouten |
last post by:
Hey,
Currently im working on a project where a dynamic database is created in
memory, the database can be of any size both in the amount of rows aswell as
in the amount of columns. The database...
|
by: MLH |
last post by:
I use a mouse-down procedure to trap right mouse
clicks and CTRL-Right mouse clicks. Running the
procedure must put honey or some other sticky
substance into my keyboard because subsequent...
|
by: Mark Phillips |
last post by:
Hello,
I am having a problem in which a file can get stuck open when a thread
that is attempting to write to it gets aborted (ThreadAbortedException
occurs). The log file gets stuck open until...
|
by: Astronomically Confused |
last post by:
using System;
using System.Collections;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
class HttpProcessor
{
private Socket s;
|
by: alyssa |
last post by:
I have written this to show table in the database on this datagrid...but when
i implement my click event i had an error msg and i don't know how to correct
it...here's the code..
private void...
|
by: alyssa |
last post by:
Hi guys,
May i know how to declare a string of binary data and pass it to the method?
For example, int a={10010001120420052314}
is it correct?
and if i have receive the binary data, may i know...
|
by: alyssa |
last post by:
SqlDataReader rdr = null;
SQLConnection con = null;
SqlCommand cmd = null;
try
{
// Open connection to the database
string ConnectionString = "server=localhost;database =
CallBilling System";...
|
by: jessebasketball |
last post by:
i am a very beginner programmer and am stuck on a very simple problem.
I am trying to make a game where the user
is presented with a scenerio and options. ie
you are standing in the parking lot...
|
by: amanjsingh |
last post by:
Hi,
I am completely new to Access. Here is something that I am experiencing...
I have this form and I search for candidate. Whatever results I get, I try to navigate from one to another and it...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |