Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you load a 150 kb (kilobyte) text files into sql server 2008?
    primarykey
    data
    text
    <p>How do you load 150 kb text files (.aspx, .cs, html, etc) into a sql server 2008 database. I'm able to load all files that are less than 64 kb so far. I have two questions; How do I get around the 64 kb limit, and is the method I'm using the best way to do this?</p> <p>Thanks for the help. </p> <blockquote> <p>Database:</p> <pre><code>file_length int, file_path varchar(250), file_string varchar(MAX) </code></pre> </blockquote> <pre><code>private static void Load_Files() { string source = HttpContext.Current.Server.MapPath("~/website/"); DirectoryInfo di = new DirectoryInfo(source); FileInfo[] files = di.GetFiles(); foreach (FileInfo f in files) { string sourceFile = f.FullName; FileStream fs_reader = new FileStream(sourceFile, FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs_reader); string content = reader.ReadToEnd(); Int32 file_length = content.Length; string CS = ConfigurationManager.ConnectionStrings["SQL_CS"].ConnectionString; SqlConnection SQL_Conn_01 = new SqlConnection(CS); string SQL_01 = "INSERT INTO Page_File_Store (file_length, file_path, file_string) VALUES (@file_length, @file_path, @file_string)"; SqlCommand SQL_File_Load = new SqlCommand(SQL_01, SQL_Conn_01); SQL_File_Load.Parameters.Add(new SqlParameter("@file_length", file_length)); SQL_File_Load.Parameters.Add(new SqlParameter("@file_path", sourceFile)); //SQL_File_Load.Parameters.Add(new SqlParameter("@file_string", content)); SqlParameter contentParameter = new SqlParameter("@file_string", SqlDbType.VarChar, -1); contentParameter.Value = content; SQL_File_Load.Parameters.Add(contentParameter); SQL_Conn_01.Open(); SQL_File_Load.ExecuteNonQuery(); SQL_Conn_01.Close(); reader.Close(); } } </code></pre>
    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.
 

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