|
|
|
ช่วยแนะนำการเขียนโค้ดเกี่ยวกับ เลือกข้อมูลจาก combobox แล้วข้อมูลอื่นๆ จะขึ้นที่ textbox และบันทึกลง Sql ค่ะ (vb.net) |
|
|
|
|
|
|
|
ตัวอย่างการ Insert จาก VB.NET ลงใน SQL Server Database
Code (VB.NET)
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim strConnString,strSQL As String
strConnString = "Server=localhost;UID=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
strSQL = "INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) " & _
" VALUES " & _
" ('" & Me.txtCustomerID.Text & "','" & Me.txtName.Text & "','" & Me.txtEmail.Text & "', " & _
" '" & Me.txtCountryCode.Text & "','" & Me.txtBudget.Text & "','" & Me.txtUsed.Text & "')"
objConn.ConnectionString = strConnString
objConn.Open()
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
Me.pnlAdd.Visible = False
Try
objCmd.ExecuteNonQuery()
Me.lblStatus.Text = "Record Inserted"
Me.lblStatus.Visible = True
Catch ex As Exception
Me.lblStatus.Visible = True
Me.lblStatus.Text = "Record can not insert Error ("& ex.Message &")"
End Try
objConn.Close()
objConn = Nothing
VB.NET/C# Connect to SQL Server Using ADO.NET
|
|
|
|
|
Date :
2016-02-13 22:10:46 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|