Click here to Skip to main content
15,358,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I sending data from 3 text-box to server program , and the server will know that the data received is from more than one text-box ??

the scenario is :
I want to make a client/server , the client will register "email , username , password " in the database in the server
how the server will know that the data come from more than one text-box , while the data send as bytes from client to server ??

thanks in advance :)
swapnilKumbhar 14-Apr-12 3:51am
If you want to store email,username and password in DataBase then use simple insert query having server DB path.
maxpower12345 14-Apr-12 4:05am
how I will know that the user name is have this length and the password and so on ?
what if the user name is more than 10 char ?
while the data will sending as a array byte through TCP/IP
maxpower12345 14-Apr-12 4:20am
can I do this in client side

ASCIIEncoding encoder = new ASCIIEncoding();
byte[] buffer = encoder.GetBytes(textBox1.Text );
byte[] buffer1 = encoder.GetBytes(textBox2.Text);
byte[] buffer2 = encoder.GetBytes(textBox3.Text);
ClientStream.Write(buffer, 0, buffer.Length);
ClientStream.Write(buffer1, 0, buffer1.Length);
ClientStream.Write(buffer2, 0, buffer1.Length);

Bala Selvanayagam 14-Apr-12 5:41am
I would have thought, if you want to write into the SQL database in the server then
you may have to open a connection from the client to the database and use an insert SQL statement and not sure why you want to use "ClientStream"..Can you please go into more detail and tell us what you are trying to achieve please ?
maxpower12345 14-Apr-12 16:00pm
I open connection and use a Stream
but how the database will separate the reserved data to column ?
[no name] 14-Apr-12 6:24am
You are connecting to your database through TCP/IP? What database are you using?
maxpower12345 14-Apr-12 16:02pm
yes , the connection to database through TCP/IP
the database is sql in C# .NET framework
Bala Selvanayagam 14-Apr-12 17:01pm
I think you are slightly confused with the way the c# .net frame work communicates with the server.

1.In your c# .NET client you have to open a SQL connection to the server with the credentials and when you open the connection the client establishes the connectivity to the server database

2.Now, for you to send the data, you will use something called SQL query / Stored Procedure as explained below in the solution 1. In the SQL query you will specifiy which text box data goes into which column of the database and you will sort of flush the query through the database connection so that the query will reach the database with the right value to the right column.

let me know, if you need any samples on this ? if this is one you are after ?
maxpower12345 15-Apr-12 6:50am
you talk about local SQL database server

but what I talk about is :
I programming program "server" the server have local SQL database in server side
while the client in the client side will connect to server through TCP/IP and sending data to "server program" so the server will save this data in it's own sql .
maxpower12345 15-Apr-12 14:49pm
oh thanks :)
your solution is right

I misunderstand the connection to database
Bala Selvanayagam 15-Apr-12 15:46pm
thats good
kashifjaat 19-May-13 1:43am
Please Send me code of this Project :-

1 solution


1. Create a stored procedure in SQL Server CREATE PROCEDURE (Transact-SQL)

2. I don't know what application is as client (WinForm/Web/WPF)
set TextLenght of the TextBoxes
You can use Regular expressions for validating email address.
.NET Framework Regular Expressions

3. Call your stored procedure from your application and set its values.
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET
maxpower12345 14-Apr-12 16:27pm
number 2 seems helpful :)

but I thought that there is specific way to send data from client to "server database"
Shahin Khorshidnia 14-Apr-12 17:00pm
Yes, There are many ways. A secure way is Web service. For example WCF. If you search google you will see!
maxpower12345 15-Apr-12 6:31am
I google it , but ..
I programming a "server program" in C# , so I don't know if the WCF can work with my program "the server" together ?
Shahin Khorshidnia 15-Apr-12 7:35am
What do you mean?!
WCF is for SOA programing and if you want to have a web service for your application then you can use WCF. It depends on you if your application can work with WCF or not (Not to WCF)
maxpower12345 15-Apr-12 14:51pm
thanks a lot :)

I understand now , your solution so helpful :)
Shahin Khorshidnia 15-Apr-12 15:37pm
You're welcome.
Happy to hear (read) this.

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900