Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Server Networking
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 Smile | :)
Posted 13-Apr-12 22:41pm
Comments
swapnilKumbhar at 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 at 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 at 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 at 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 at 14-Apr-12 16:00pm
   
I open connection and use a Stream
but how the database will separate the reserved data to column ?
Wes Aday at 14-Apr-12 6:24am
   
You are connecting to your database through TCP/IP? What database are you using?
maxpower12345 at 14-Apr-12 16:02pm
   
yes , the connection to database through TCP/IP
the database is sql in C# .NET framework
Bala Selvanayagam at 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 at 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 at 15-Apr-12 14:49pm
   
oh thanks :)
your solution is right
 
I misunderstand the connection to database
Bala Selvanayagam at 15-Apr-12 15:46pm
   
thats good
kashifjaat at 19-May-13 1:43am
   
Please Send me code of this Project :-
kashif_jaat@yahoo.com

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hello
 
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)
But:
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
  Permalink  
Comments
maxpower12345 at 14-Apr-12 16:27pm
   
thanks
number 2 seems helpful :)
 
but I thought that there is specific way to send data from client to "server database"
Shahin Khorshidnia at 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 at 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 at 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 at 15-Apr-12 14:51pm
   
thanks a lot :)
 
I understand now , your solution so helpful :)
Shahin Khorshidnia at 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)

  Print Answers RSS
0 OriginalGriff 195
1 Afzaal Ahmad Zeeshan 152
2 ProgramFOX 130
3 Maciej Los 130
4 den2k88 80
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 14 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100