|
|
|
อยากทราบว่า จะเก็บข้อมูลจาก DataGridView ลงใน SQL Server 2008 ยังไงอ่ะคะ (VB) |
|
|
|
|
|
|
|
Code (VB.NET)
Dim objConn As New SqlConnection
Dim strConnString, strSQL As String
Dim objCmd As SqlCommand()
strConnString = "Server=localhost;UID=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
objConn.ConnectionString = strConnString
objConn.Open()
For i = 0 To DataGridView.RowCount - 1
strSQL = "INSERT INTO files (Name,FilesName,FilesType) " & _
" VALUES " & _
" (@sName,@sFilesName,@sFilesType)"
objCmd = New SqlCommand(strSQL, objConn)
objCmd.Parameters.Add("@sName", SqlDbType.VarChar).Value = Grid.items(i).value
objCmd.Parameters.Add("@sFilesName", SqlDbType.Binary).Value = Grid.items(i).value
objCmd.Parameters.Add("@sFilesType", SqlDbType.VarChar).Value = Grid.items(i).value
objCmd.ExecuteNonQuery()
Next
objConn.Close()
objConn = Nothing
|
|
|
|
|
Date :
2011-09-07 17:42:41 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|