Dim column As New System.Windows.Forms.DataGridViewComboBoxColumn
'เรียกใช้
sb = New StringBuilder()
sb.Append("SELECT StaffID,StaffName FROM Staff")
Dim sqlIni As String
sqlIni = sb.ToString()
com = New SqlCommand()
With com
.CommandText = sqlIni
.CommandType = CommandType.Text
.Connection = Conn
dr = .ExecuteReader()
End With
If dr.HasRows Then
Dim dtDepartment As DataTable
dtDepartment = New DataTable()
dtDepartment.Load(dr)
With column
.HeaderText = "คนที่"
.DisplayMember = "StaffName"
.ValueMember = "StaffID"
.DataSource = dtDepartment
End With
End If
dr.Close()
Tag : .NET, Ms SQL Server 2005, Ms SQL Server 2008, Win (Windows App), VB.NET, VS 2008 (.NET 3.x)
Date :
2012-05-08 16:34:43
By :
Guest
View :
1103
Reply :
2
No. 1
Guest
ประมานนี้หรือป่าวครับ
Code (VB.NET)
Dim sb As StringBuilder
sb = New StringBuilder()
Dim orderCommandObject As New SqlCommand
Dim orderSQLcommand As New StringBuilder
orderSQLcommand.Append("insert into Tbl_Test(MO,LABEL,Last_Upd)")
orderSQLcommand.Append(" VALUES (@MO,@LABEL,@Last_Upd)")
With orderCommandObject
.Connection = myCNN
.CommandText = orderSQLcommand.ToString()
.Parameters.Clear()
.Parameters.Add("@MO", SqlDbType.VarChar).Value = txt_mo.Text
.Parameters.Add("@LABEL", SqlDbType.VarChar).Value = txt_sn.Text.Trim
.Parameters.Add("@Last_Upd", SqlDbType.VarChar).Value = dRemoteDate
.ExecuteNonQuery()
End With