我想通過linq插入數據到sql概念。我寫下了這樣的代碼。這裏的客戶是我想要插入數據的表名。如何實現它? 以下代碼無法正常工作。如何通過這個概念插入數據。如何通過使用linq到sql概念插入數據
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim context As New linq_to_sql_classesDataContext
Dim custid As New Customer
custid.CustomerID = Trim(txt_custid.Text)
custid.CompanyName = Trim(txt_companyname.Text)
custid.ContactName = Trim(txt_contactname.Text)
custid.ContactTitle = Trim(txt_contacttitle.Text)
custid.Address = Trim(txt_address.Text)
custid.City = Trim(txt_city.Text)
custid.Region = Trim(txt_region.Text)
custid.PostalCode = Trim(txt_postalcode.Text)
custid.Country = Trim(txt_country.Text)
custid.Phone = Trim(txt_phone.Text)
custid.Fax = Trim(txt_fax.Text)
context.Customers.Attach(custid)
context.SubmitChanges()
End Sub
謝謝
問題沒有解決..!當點擊提交按鈕然後沒有行動將執行 – Mihir 2011-02-15 11:40:20