October 2007 Entries

chunking binary or xml into sql

this is a little unique of a setup. i'm having to update a varbin field, but the data that is coming in from the other sources is being cast from xml. so i'm sort of replicating the stupid thing we are doing on the other side, but it seems like a good code sample for this particular method. if you wanted to chunk up xml, you could use this method.  using (SqlConnection cn = new SqlConnection(cs)) {string staging_sql = @" create table ##t (t varchar(max)); insert ##t select '';"; string load_sql = @"update ##t set t .write(@a,null,0)";string update_and_cleanup_sql = @" update tablewithvarbincolumn set varbincolumn =...

posted @ Monday, October 29, 2007 2:28 PM | Feedback (0)

chunking varbinary into sql2005

//reference this metholodogy justification at // http://www.lacoude.com/Docs/public/public.aspx?doc=SQL90XML.PDF int bufferSize = 0;byte[] buffer = new byte[8040]; string update_sql = @"update tablewithblobs set blobcolumn .write(@a,null,0) where id = @b"; using (FileStream fs = File.Open(abinaryfilepath, FileMode.Open, FileAccess.Read))using (BinaryReader br = new BinaryReader(fs)) using (SqlConnection cn = new SqlConnection(cs))using (SqlCommand cmd = new SqlCommand(update_sql, cn)) { cmd.CommandTimeout = 0;cmd.Parameters.Add("@a", SqlDbType.VarBinary, bufferSize); cmd.Parameters.AddWithValue("@b", v1); cn.Open();while ((bufferSize = br.Read(buffer, 0, buffer.Length)) != 0) { cmd.Parameters[0].Value = buffer; cmd.ExecuteNonQuery(); } cn.Close(); }     note that you will have to zero out the field if it's not empty by setting it to 0x0 first.

posted @ Friday, October 26, 2007 10:56 PM | Feedback (0)

HTTP Status and SubStatus codes

HTTP Status HTTP SubStatus Definition 100   Continue 101   Switching pools 200   OK.  The clinet request has succeeded 201   Created 202   Accepted 203   Non-authoritative information 204   No content 205   Reset content 206   Partial content 301    Permanent Redirect. 302    Object Moved 304    Not Modified. 307    Temporary redirect. 400    Cannot resolve the request. 401.x    Unauthorized. 401 1  Access is denied due to invalid credentials. 401 2  Access is denied due to server configuration favoring an alternate authentication method. 401 3  Access is denied due to an ACL set on the requested resource. 401 4  Authorization failed by a filter installed on the Web server. 401 5  Authorization failed by an ISAPI/CGI application. 401 7  Access denied by URL authorization policy on the Web server. 403.x None  Access is denied. 403 1  Execute access is denied. 403 2  Read access is denied. 403 3  Write access is denied. 403 4  SSL is required to view this resource. 403 5  SSL 128 is required to view this resource. 403 6  IP address of the client has...

posted @ Thursday, October 04, 2007 3:17 PM | Feedback (0)