PDA

View Full Version : سوال: TableAdapter.delete



a1b2uu
سه شنبه 09 آذر 1389, 11:17 صبح
سلام دوستان
Insert کردن در sql رو با کد زیر انجام میدم و درست کار میکنه.

ServiceCostTableAdapter.InsertQueryservicecost(Dep artmentID:="" & Ldepid.Text & "", Cost:="" & Txtpricetype.Text & "", TypeOfService:="" & Txttypename.Text & "", TypeOfServiceID:="" & Txttypename.Text & "")

ولی delete و update رو نمیتونم با این روش انجام بدم.





ServiceCostTableAdapter.DeleteQueryservicecost(؟)

ServiceCostTableAdapter.UpdateQueryservicecost(؟)


قبلا با روش زیر انجام میدادم و درست کار میکنه ولی می خوام از روش بالا استفاده کنم.

Dim a As New SqlConnection
a.ConnectionString = "Data Source=localhost;Initial Catalog=matab;Integrated Security=True"
Dim b As New SqlCommand
Dim c As New SqlDataAdapter
c.DeleteCommand = b
c.DeleteCommand.CommandType = CommandType.Text
c.DeleteCommand.CommandText = "use matab delete servicecost where (DepartmentId='" & (txtID.Text.ToString) & "') "
c.DeleteCommand.Connection = a
c.DeleteCommand.Connection.Open()
c.DeleteCommand.ExecuteNonQuery()
c.DeleteCommand.Connection.Close()

MsgBox("اطلاعات با موفقیت حذف شد", MsgBoxStyle.OkOnly, "حذف اطلاعات")