Академический Документы
Профессиональный Документы
Культура Документы
Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports System.IO
Namespace sqlFileExample
Public Partial Class frmMain
Inherits Form
Private objConn As New SqlConnection()
Private strSqlConn As String = "Data Source=localhost\sqlexpress;Initial
Catalog=db2;Integrated Security=True"
'grab schema
adapter1.SelectCommand = cmd1
'
adapter1.Fill(tbl1)
' fill the data table as specified
objGrid.DataSource = tbl1
' set the grid to display data
End Sub
objFileStream.Read(objData, 0, intLength)
objFileStream.Close()
objRow = objTable.NewRow()
objRow("fileName") = strPath(strPath.Length - 1)
'clip the full path - we just want last part!
objRow("fileSize") = intLength / 1024
' KB instead of bytes
objRow("attachment") = objData
'our file
objTable.Rows.Add(objRow)
'add our new record
objAdapter.Update(objTable)
End Sub
sqlCmd.Parameters.AddWithValue("@attachId", strId)
Dim objAdapter As New SqlDataAdapter(sqlCmd)
Dim objTable As New DataTable()
Dim objRow As DataRow
objAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
Dim sqlCmdBuilder As New SqlCommandBuilder(objAdapter)
objAdapter.Fill(objTable)
objRow = objTable.Rows(0)