با سلام
می خواستم بدونم کدوم مورد برای کارهای ویرایش و درج و حذف استفاده کنم بهتره؟
Insert ,Delete و Update یک دیتا ست درست کنم و از دستورات
یا با استفاده از دستورات کامند و توابع درج و غیره ای که خودم نوشتم
لازم به ذکر است که من پارامترهارا توسط یه دیتا روبه فرم دیگه می فرستم و در آنجا عملیات مذکور را انجام می دهم.
--------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub Page_Load (ByVal sender As System.Object , ByVal e As System.EventArgs ) Handles MyBase.PreRender
مرحله اول : ايجاد Connection
Dim ContactMgmt As New SqlConnection ("Server=(local) ; database=Contact;Trusted_Connection=yes"
Dim adapterContactMgmt As New SqlDataAdapter("Select * From Contact",ContactMgmt)
مرحله دوم : ايجاد يک Data Set
Dim dsContacts As New DataSet( )
adapterContactMgmt.SelectCommand.CommandText = "SELECT * FROM Contact"
مرحله سوم : ايجاد دستورات Insert ,Delete و Update بصورت اتوماتيک
Dim CmdContanctMgmt As SqlCommandBuilder = New SqlCommandBuilder ( adapterContactMgmt )
مرحله چهارم : ايجاد يک Row جديد
Dim rowInsert As DataRow = dsContacts.Tables("Contact").NewRow
RowInsert("Fname") = "مديريت سايت "
RowInsert("Lname ") = "مديريت سايت"
RowInsert("Email ") ="Info@Srco.ir"
dsContacts.Tables ("Contact") .Row.Add(RowInsert)
مرحله پنجم : بهنگام سازی بانک اطلاعاتی
adapterContactMgmt.Update(dsContacts.Tables("Conta ct")
End Sub
--------------------------------------------------------------------------------------------------------
public
void InsertRec(string nam1,
string phonenumbre11, string phonenumbre12, string phonenumbre13)
{
try
{
string oql = "INSERT INTO booknum(nam, phonenumbre1, phonenumbre2, phonenumbre3)VALUES('" +
nam1 + "','" + phonenumbre11 + "','" + phonenumbre12 + "','" +
phonenumbre13 + "')";
connect conn = newconnect();
conn.ExecQuery(oql}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}