احنا اخدنا مثال على ال connective mode
عملنا database=company
table=Emp
وبعدين بنعمل الفروما عباره عن 4 textbox
id / name/ address / salary
2 buttons insert / delete
using system.data.sqlclient; // ده عشان فتح ال connection
sqlconnection con=newsqlconnection("server=s1;database=company;integratedsecurity=sspi");
//السطر ده بيوضح اسم السيرفر ونوع الحمايه بس لسه هنعرفه قدام
sql command com=new sql command();
com.connection=con; //اللى هينفذ ال كوماند بتاع الconnection اللى اسمه con
com.command type=command type.text;
com.commandText="insert into Emp values("+int.parse(textbox1.text)+",
'"+textbox2.text+"','"+textbox3.text+"',"+int.parse(textbox4.text)+")"
//ده بقى بيقولك فيه ان اى string لازم يكتب بين single quote
عشان كده كان بيحط ' ' فى ال textbox بتاعه ال name&address
ومحطش فى ال id &salary
وحته "+ int.parse"
ديه عشان انا باخد من الفورم
وده طبعا كله لل button بتاع insert
/////////////////////////////////////////////////////////////////////////////////////////////////
بالنسبه ل delete
تكتبى نفس كود ال insert
لكن باختلاف السطر ده
con.command Text="delete from Emp where id="+int.parse(textbox1.Text)+"";
//////////////////////////////////////////////////////////////////////////////////////////////////
الفورما التانيه
2 textbox : emp-address/no of employee
button= search
احنا بناخد نفس الكود اللى فات ونغير فى
com.commandText="{select count (id) from Emp where address=' "+Textbox1.text+" '";
con.open();
int x=(int) com.Execute scalar();
con.close();
textbox2.text=X.Tostring();
///////////////////////////////////////////////////////////////
معلش والله بجد مش عارفه اكتب احسن من كده
كلمه عربى وكلمه انجليزى