Mediachase FileUploader.NET 1.9 Framework Help

McHttpPostedFile.SaveAs Method (String, String, String, SqlParameter[])

Saves the contents of an uploaded file into MS SQL database.

[Visual Basic]
Overloads Public Sub SaveAs( _
   ByVal ConnectionString As String, _
   ByVal TableName As String, _
   ByVal ColumnName As String, _
   ParamArray PrimaryKeys As SqlParameter() _
)
[C#]
public void SaveAs(
   string ConnectionString,
   string TableName,
   string ColumnName,
   params SqlParameter[] PrimaryKeys
);

Parameters

ConnectionString
A sql connection string that includes the source database name, and other parameters needed to establish the initial connection. The default value is an empty string.
TableName
A table name for the table that the current file stream will encapsulate.
ColumnName
A column name for the column that the current file stream will encapsulate.
PrimaryKeys
A primary keys collection for the row that the current file stream will encapsulate.

Example

Example saves a new file into MS SQL database named File with FileId:int and Data:image columns.

            private void btnSubmit_ServerClick(object sender, System.EventArgs e)
            {
            	if(McFileUp.PostedFile!=null)
            	{
            		int FileId = 0;
                
            		//TODO: Create a new record and assign FileId variable.
                
            		McFileUp.PostedFile.SaveAs("Data source=(local);Initial catalog=TestDB;User Id=sa;Password=","File","Data",new SqlParameter("@FileId",FileId));
            	}
            }
            

See Also

McHttpPostedFile Class | Mediachase.FileUploader.Web Namespace | McHttpPostedFile.SaveAs Overload List