السلام عليكم ورحمة الله وبركاتة
-------------------------
فى البداية أقوم الان بتطوير برنامج Chat مكون من كلينت وسيرفر
الان افوم بأضافة خاصية Register New Account للكلينت ونظامى يعتمد على التخزين فى قاعدة بيانات Access
قمت بإضافة هذا الكود للسيرفر
اقتباسprocedure TForm1.ServerSocket1ClientRead(Sender: TObject;Socket: TCustomWinSocket);
type
UserDetails = Record
Name : String;
Address: String;
Tel : String;
Email: String;
Sex : String;
Age : String;
end; {type}
var
Data : String;
Details : UserDetails;
i : Integer;
begin
// Assign the Data to a Varable so we can play with it
Data := ServerSocket1.Socket.Connections[0].ReceiveText;
// The incomming fields for the data base are seperated
// with ','s so we can use the .CommaText property of the
// list box to seperated them into individual fields
listbox1.Items.CommaText := (Data);
// We now need to get the data out of the list box and assign
// The details to Our record type we defined earlier, for this
// I am going to use a For loop with a case statement nested inside
// This tells the computer to do the following instructions for each item in the list
// And also incriments i so that we know which data it is we are dealing with
for i := -1 to listbox1.Count do
begin
// This is called depending on the state of i
case i of
// If i is 0 then we know this is the Name Item So we assign it
0 : Details.Name := ListBox1.Items.Strings;
// If i is 1, it is the address item, so we add this to our record
1 : Details.Address := ListBox1.Items.Strings;
// If i is 2 it is the Phone Number Item, So we add this to our record
2 : Details.Tel := ListBox1.Items.Strings;
// If i is 3 it is the users Email so we add this to our record also
3 : Details.Email := ListBox1.Items.Strings;
// And So on
4 : Details.Sex := ListBox1.Items.Strings;
// And so on
5 : Details.Age:= ListBox1.Items.Strings;
end; {case}
end; {for}
// We no longer need the items in the List box, so we can clear it
listbox1.Clear;
with ADOTable1 do begin // With the ADO Table we are going to
Insert; // INSERT
// We add the details of Detials.Name to the Name Feild on the database
FieldByName('Name').AsString := Details.Name ;
// Same as above but different Field
FieldByName('Address').AsString := details.Address ;
// And so on.....
FieldByName('Telephone Number').AsString := Details.Tel ;
FieldByName('Email Address').AsString := Details.Email ;
FieldByName('Sex').AsString:= Details.Sex ;
FieldByName('Age').AsString:= Details.Age ;
Post; // Post the Data to the database
end; // end with statement
// now all we have to do is close the connection from the client
ServerSocket1.Socket.Connections[0].Close;
end;
لكى يستجيب للاوامر المستقبلة من الكلينت ونجح الكود تماماً ولكن عندما اقوم بتشغيل الكلينت وأقوم بعمل Connect الاحظ ظهور Error معى فى ListBox1
سوف أقوم بإرفاق صورة عندما حاولت أكتب النك نيم بتاعى Nickname وكان هوه Arabteam2000كتبهالى فى اللست بوكس
وعندما أحاول ايضا التكلم مع صديق فى PM (الخاص) القى المعلومات بتنضاف فى اللست بوكس ListBox1 بدون معنى
أنا ميش كاتب اى حاجة فى السيرفر توحى بأنى بستقبل البيانات على ال ListBox1 :s
اسف على الإطالة
