Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat Datatype to use for this so that the image can upload to the SQL Server?
    primarykey
    data
    text
    <p>Visual Studio, c#, SQL 2005 server. I"m trying to match the .dbml table data type with my .cs file. The goal is to allow an image to load to the database. So far it is not working. The issue seems to be related to the file type for the FileContent column. I have tried several different variations, but none have worked. </p> <pre><code>&lt;Column Name="FileName" Type="System.String" DbType="NVarChar(100)" CanBeNull="true" /&gt; &lt;Column Name="FileType" Type="System.String" DbType="NVarChar(100)" CanBeNull="true" /&gt; &lt;Column Name="FileSize" Type="System.int32" DbType="int" CanBeNull="true" /&gt; &lt;Column Name="FileContent" Type="System.Data.Linq.Binary" DbType="varbinary(MAX)" CanBeNull="true" /&gt; </code></pre> <p>SQL Server Columns<br /> Applicant_PK(PK,int,notnull)<br /> FileName(nvarchar(100),null)<br /> FileType(nvarchar(100),null)<br /> FileSize(int,null)<br /> FileContent(varbinary(max),null)<br /></p> <pre><code> void CreatePreApplication() { Pre_Application = new PreApplication(); Pre_Application.FileName = Path.GetFileName(ctrFile.PostedFile.FileName); Pre_Application.FileType = ctrFile.PostedFile.ContentType; Pre_Application.FileSize = ctrFile.PostedFile.ContentLength; byte[] fileContent = new byte[ctrFile.PostedFile.ContentLength]; ctrFile.PostedFile.InputStream.Read(fileContent, 0, ctrFile.PostedFile.ContentLength); Pre_Application.FileContent = fileContent; public class PreApplication </code></pre> <p>{ public int DatabaseId { get; set; } public String FileName { get; set; } public String FileType { get; set; } public int FileSize { get; set; } public byte[] FileContent { get; set; } public PreApplication()</p> <pre><code> { PreApplicationsDataContext db = new PreApplicationsDataContext( "Data Source=THESQLSERVER;Initial Catalog=THECONNECTIONSTRING;Integrated Security=True"); tblPreApplication preApp = new tblPreApplication(); preApp.FileName = FileName; preApp.FileType = FileType; preApp.FileSize = FileSize; preApp.FileContent = (byte[])FileContent; try { db.tblPreApplications.InsertOnSubmit(preApp); db.SubmitChanges(); DatabaseId = preApp.Applicant_PK; return preApp.Applicant_PK; } catch { DatabaseId = 0; return 0; } } </code></pre> <p>Thanks for looking at this. I am a novice at programming, so if you ask me a question, please keep this in mind.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload