Storing ASP.NET 2.0 Profiles In SQL Server 2005

Oct 17, 2007

Hi Everyone,

I have an e-commerce site that uses Profiles in ASP.NET 2.0 to store items in a shopping cart.  The problem is that we are now using LDAP authentication, so we are getting rid of the ASPNETDB membership database that stores the profile values.  How can get the shopping cart functionalty to work with SQL Server 2005?  How can I store the profile object in a SQL Server instead of the ASP.NET memberships database?

Here is the profile field:

  <profile enabled="true">
      <properties>
        <add name="Cart" serializeAs="Binary" type="Commerce.ShoppingCart" allowAnonymous="true"/>
      </properties>
    </profile>

 

Thank you in Advance

-Sam 

 

View 1 Replies


ADVERTISEMENT

SQL Server And Profiles.

Mar 16, 2006

I've created a website using Microsoft's built-in profile/membership system. I'm used to referring to these elements without actually having to interact with the underlying tables. Thus, I type:Profile.UserName when I want a users UserName rather than querying the database manually.Now, I need to create a scheduled job in SQL that sends emails out based upon user preferences specified under Profile. Is there a way to use Profile within SQL Server 2005?David.

View 1 Replies View Related

SQL Server Configuration For ASP.NET 2.0 Profiles

Apr 12, 2006

Hi,
I want to configure SQL Server 2005 Express to work with profiles and that kind of ASP.NET 2.0 things :)
The problem is, when I run aspnet_regsql.exe I can't get a list of databases, and when I manually enter the database name, I get the same error."(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
I've enabled the named pipes and tcp/ip connections in the Server Configuration Manager.I've also tried multiple logins.
I run the sql server locally.I can connect with my website to it, I can use the Management Studio Express (with win auth).
But I can't get those tables configured :(
Anybody got an idea?
Thanks in advance.

View 2 Replies View Related

SQL Mail - MAPI Profiles On Windows Server 2003

Sep 16, 2005

Scenario:DBMS: SQL Server 2000OS: Windows Server 2003Goal:Enable SQLMAIL via Internet MailProblem:How do I set up the MAPI profile for the SQL Server service account?On Windows 2000 Server, I can use "Control Panel"/"Mail" tocreate a MAPI profile for the SQL Server service account, and thenreference that profile for SQLMAIL in SQL Server and SQL Server Agent.But on Windows Server 2003, there is no "Mail" applet in "Control Panel".How do I create a MAPI profile, for the SQL Server service account,on Windows Server 2003?

View 5 Replies View Related

Storing Objects In SQL Server 2005

Oct 24, 2006

Hi All,I am looking to store a DataSet into a Table in SQL Server 2005, or any object for that matter.   I cannot find any code to perform.  Can anyone help?Many Thanks,Peppa.   

View 2 Replies View Related

Storing Images In Sql Server 2005

Jun 5, 2006

Hi There

I have not had much luck finding info in BOL.

I have a directory with many images, i need to load these images into sql server.We want to staore them in the database instead of the file server.

What is the best way to do this? TSQL (i am hoping), .NET code or maybe even SSIS ?

I have been reading what i can find in BOL basically all i know so far is that image data type will be no more in the future and i should use a varbinary(max) data type.
Basically i need a good link or something that can demonstrate how one can go about loading images into Sql Server 2005.



Thanx

View 6 Replies View Related

Storing A PDF File Into SQL Server 2005?

Jan 16, 2008

Does anyone know whats wrong with my code?
~Nothing wrong with my code, code is correct!

I let it run and it keeps saying that the file does not exist. Seem as though, the path of my file doesn't exist! Any suggestions on how to program the path of my file so I can be able to retreive it such as open the file and access the file?

CODE:


Imports System

Imports System.Data

Imports System.Data.Sql

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Imports System.Web

Imports System.Configuration

Imports System.Reflection

Imports System.Security.Permissions.FileIOPermission

Imports System.IO

Imports System.Collections

Imports System.Collections.Generic

Imports System.Windows.Forms

Imports System.Security.Permissions

Imports System.Windows.Forms.Form

'<Assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Name:="Local Intranet")>

'<Assembly: PermissionSetAttribute(SecurityAction.RequestOptional, Unrestricted:=True)>



Public Class Form1

Inherits Form

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim SQL As String

Dim rawData() As Byte

Dim RowsAffected As Integer

Dim filename As String

filename = "H:My Documentsabc.pdf"

Try

If System.IO.File.Exists(filename) Then

Dim filePermission As New System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.Read, System.Security.AccessControl.AccessControlActions.View, filename)

filePermission.Demand()

Else

MessageBox.Show("file does not exist", "File", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If

Dim fs As FileStream

fs = New FileStream(filename, FileMode.Open, FileAccess.Read)

Dim FileSize = Convert.ToInt32(fs.Length)

rawData = New Byte(FileSize) {}

fs.Read(rawData, 0, FileSize)

SQL = String.Format("INSERT INTO test_file_save(FILE_ID, FILE_NAME, FILE_SIZE, CREATE_FILE) VALUES({0}, {1}, {2}, {3})", _

1, filename, FileSize, rawData)

Using Conn As New SqlConnection("server=1234;" _

& "uid=F_User;" _

& "pwd=password;" _

& "database=Database")

Using Cmd As New SqlCommand("sp_InsertPDF", Conn)

Cmd.CommandType = CommandType.StoredProcedure

Cmd.Parameters.Add(New SqlParameter("@FILE_ID", 1))

Cmd.Parameters.Add(New SqlParameter("@FILE_NAME", filename))

Cmd.Parameters.Add(New SqlParameter("@FILE_SIZE", FileSize))

Cmd.Parameters.Add(New SqlParameter("@CREATE_FILE", rawData))

fs.Close()

Conn.Open()

RowsAffected = Cmd.ExecuteNonQuery()

End Using

End Using

MessageBox.Show("File Inserted into database successfully!", _

"Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)

Catch ex As Exception

MessageBox.Show("There was an error: " & ex.Message, "Error", _

MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try







End Sub

End Class

View 5 Replies View Related

SQL Server 2008 :: Migrate All DB Mail Profiles To New Server?

Oct 6, 2015

I need to migrate the all dbmail profiles(around 15) from Old server to new SQL instance.

is their any script or any way to do so that i can perform all at a time instead of doing manually.

View 0 Replies View Related

Storing Arabic Data In Db(sql Server 2005)

Oct 1, 2007

Hi,
How to insert or store arabic data into a table in sql server 2005, also i want to retrieve it as arabic format.But now it insert  (?????) like this.Please help me to find a solution. 
Regards
Sabna S

View 3 Replies View Related

Storing Large Files In The SQL Server 2005

Feb 9, 2006

I have a table that I'm inserting a file into and using the Image data type to store the binary object.  Now the code below works fine for files around 1.5 MB, but anything larger and it's like the code won't even execute and I get a Page Not found error.
I'm in the process of running some traces to find out what's going on in the backend, but I'm assuming there's something amiss with my code.  The Image data type should handle files that size with no problem but for some reason it isn't.
Does anyone see anything wrong?
Thanks
Dim iLength As Integer = CType(File1.PostedFile.InputStream.Length, Integer)
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String = File1.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength) 'byte array, set to file size

'strip the path off the filename
i = InStrRev(File1.PostedFile.FileName.Trim, "")
If i = 0 Then
sFileName = File1.PostedFile.FileName.Trim
Else
sFileName = Right(File1.PostedFile.FileName.Trim, Len(File1.PostedFile.FileName.Trim) - i)
End If
conn = New SqlConnection(eco)
conn.Open()
cmd = New SqlCommand("INSERT INTO ECO_Attachments (ECOID, FromType, DocName,OldRev,NewRev,NtLogin,DisplayName, FileName, FileSize, FileData, ContentType) VALUES (@ECOID, @FromType,@DocName,@OldRev,@NewRev,@NtLogin,@DisplayName, @FileName, @FileSize, @FileData, @ContentType) ")
cmd.Connection = conn
Try
File1.PostedFile.InputStream.Read(bytContent, 0, iLength)
With cmd
.Parameters.Add("@ECOID", SqlDbType.Int)
.Parameters.Add("@FromType", SqlDbType.NVarChar, 50)
.Parameters.Add("@DocName", SqlDbType.NVarChar, 250)
.Parameters.Add("@OldRev", SqlDbType.NVarChar, 50)
.Parameters.Add("@NewRev", SqlDbType.NVarChar, 50)
.Parameters.Add("@NTLogin", SqlDbType.NVarChar, 100)
.Parameters.Add("@DisplayName", SqlDbType.NVarChar, 200)
.Parameters.Add("@FileName", SqlDbType.NVarChar, 255)
.Parameters.Add("@FileSize", SqlDbType.Real)
.Parameters.Add("@FileData", SqlDbType.Image)
.Parameters.Add("@ContentType", SqlDbType.NVarChar, 50)
.Parameters("@ECOID").Value = ECOID
.Parameters("@FromType").Value = From
.Parameters("@DocName").Value = DocName
.Parameters("@OldRev").Value = OldRev
.Parameters("@NewRev").Value = NewRev
.Parameters("@NTLogin").Value = NTLogon
.Parameters("@DisplayName").Value = DisplayName
.Parameters("@FileName").Value = sFileName
.Parameters("@FileSize").Value = iLength
.Parameters("@FileData").Value = bytContent
.Parameters("@ContentType").Value = sContentType
.ExecuteNonQuery()
'.ExecuteScalar()
End With
Catch ex As Exception
Response.Write(ex)
'Handle your database error here
conn.Close()
End Try

View 1 Replies View Related

Storing Image In Sql Server 2005 In Binary Format?

Nov 1, 2006

please mail me at lavkesh_kumar@yaho.com

View 2 Replies View Related

Storing/Retrieving Flash Files In/from Sql Server 2005

Dec 17, 2007

Hi There,
Can I store flash files in the database. I have a table with one of the columns as varbinary datatype. Previously, I was saving images (as filebytes) into this column. But now I need to implement something to store the flash file. So, is it possible to store flash files in the database and retrieve them and display them in an asp.net page?
Thanks a lot for your suggestion!!
 

View 8 Replies View Related

Storing SQL Server 2005 Objects And Queries In Perforce

Jan 29, 2007

We are trying to use source control to store our database objects andqueries in Perforce. The general idea is to produce scripts whichcreate all objects in the DB and then store the SQL in source control.Has anyone done this before and can suggest some advice? Alternativelyif anyone has other methods for using source control on a database,could you please let me know?Also, is there any automated way of extracting individual scripts forobject creation from the database?

View 2 Replies View Related

Storing IEEE 754 Floats In SQL Server 2005 (NaN, +/- Infinity)

Nov 17, 2006

Hi all,

Is there a way to get SQL Server 2005 to store NaN and Positive and Negative infinity values for double precision floats? It used to work fine under SQL 2000 and works great under MS Access, but we are updating our scientific application, and really need to be able to store this information efficiently under SQL Server 2005. We really want to dump Access because of database storage limitations.

It really amazes me that there is not more support for this as the limitation really makes it hard to store a lot of our simulation data. I guess SQL Server is more geared for financial data then scientific data. I know that Oracle supports this but we rather stick with SQL Server if we can.

We really want to avoid having to have an extra column to store this, that would be disastrous. NaN could be stored as null values. And, no, we cannot map +/- Infinity to Min and Max double values. We definitely need the distinction there.

Another post I read talked about custom user types€¦ but I€™m not sure how well that will work with our analysts pulling the data into other tools, like Excel.

Any help or suggestions would be appreciated. It just boggles the mind that SQL Server does not seem to handle true IEEE 754 doubles. How is Microsoft going to deal with C# 3.0 and DLinq support? The issue must show up there.

Anyway,

Thanks much.
James.

View 4 Replies View Related

Storing Time-series Data In SQL Server 2005

May 1, 2007

Hi all,

I'm wondering what is the best way to store time-series data in an SQL database?? I've done a bit of investigating on the rrdtool (round robin database tool) that is used in a lot of nix based solutions for monitoring network equipment. I have a need to collect performance data from servers and routers and then produces some nice graphs from that data. I'm just not sure who i should store that data without the database growing to some huge size.



Any suggestions?

View 1 Replies View Related

Need Help With Taking Data From A Card Reader And Storing It Into SQL Server 2005

Feb 7, 2007

I'm using a Hemisphere West MSR-152 card reader. I need to take data from the reader and store it into SQL Server 2005 Express. Can anyone give ideas on how to do this (sample code recommendations). I'm using visual studio 2005 express and I code with VB.NET.

View 3 Replies View Related

Error While Storing A Zip File With Size More Than 1MB In MS SQL Server 2005 Express

Aug 9, 2007

I want to store a Zip file as a BLOB, but I get an error:
"File 'C:<path of mdf file> ' appears to have been truncated by the operating system. Expected size is 2560KB but actual size is 1536KB "
whenever the BLOB exceeds 1MB.

Any suggestions? How can I store larger .ZIP files to the Database?
I am using MS SQL 2005 Express and the data type that I gave for the column to store Blob is "varbinary(MAX)".

I am inserting byte array in to this field.
It works fine for a zip file less than 1MB but as soon as the zipped file size increases beyond 1MB, lots of error pop-up and then the database is not readable. Its says that, the data in the data base may have been corrupted...

View 5 Replies View Related

How To Encrypt My Password Or Sensitive Data Before Storing Them In A Database , Using SQL Server 2005?[urgent Plz Help]

Jan 7, 2007

Hi there ,1. i have a database and i want to encrypt my passwords before storing my records in a database plus i will later on would require to  authenticate my user so again i have to encrypt the string provided by him to compare it with my encrypted password in database below is my code , i dont know how to do it , plz help 2. one thing more i am storing IP addresses of my users as a "varchar" is there a better method to do it , if yes plz help me    try        {            SqlConnection myConnection = new SqlConnection();            myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["projectConnectionString"].ConnectionString;            SqlDataAdapter myAdapter = new SqlDataAdapter("SELECT *From User_Info", myConnection);            SqlCommandBuilder builder = new SqlCommandBuilder(myAdapter);            DataSet myDataset = new DataSet();            myAdapter.Fill(myDataset, "User_Info");            //Adding New Row in User_Info Table               DataRow myRow = myDataset.Tables["User_Info"].NewRow();            myRow["user_name"] = this.user_name.Text;            myRow["password"] = this.password.Text; // shoule be encrypted             //not known till now how to do it                       myRow["name"] = this.name.Text;            myRow["ip_address"] = this.ip_address.Text;                        myDataset.Tables["User_Info"].Rows.Add(myRow);            myAdapter.Update(myDataset, "User_Info");            myConnection.Close();            myConnection.Dispose();        }        catch (Exception ex)        {            this.error.Text = "Error ocurred in Creating User : " + ex.Message;        }  

View 3 Replies View Related

Transactions And Profiles

May 26, 2006

HiI'm trying to make a transaction with the TransactionScope class and if I modify a profile and call ProfileBase.Save(), it throws an exception with the message: "MSDTC is unavailable".thanks

View 1 Replies View Related

Sending Uploaded Image To Data Access Class When Storing Image In SQL Server 2005

Apr 20, 2007

I am using the 3-tiered architecture design (presentation, business laws, and data acess layers). I am stuck on how to send the image the user selects in the upload file control to the BLL and then to the DAL because the DAL does all the inserts into the database. I would like to be able to check the file type in the BLL to make sure the file being uploaded is indeed a picture. Is there a way I can send the location of the file to the BLL, check the filetype, then upload the file and have the DAL insert the image into the database? I have seen examples where people use streams to upload the file directly from their presentation layer, but I would like to keep everything seperated in the three classes if possible. I also wasn't sure what variable type the image would be in the function in the BLL that receive the image from the PL. If there are any examples or tips anyone can give me that would be appreciated.

View 2 Replies View Related

Matching Users Profiles Using Sql

May 5, 2007

Hi folks
I have a section in my networking site where people can write things about themselves, such as likes dislikes, hobbies etc for their profile.
I am looking to provide a very basic profile matching service, and have done a bit of searching to find out what the best way to approach this feature is. I have looked at using the sql LIKE clause, but since the profile information can be any length, there seem to be too many variables to account for. I have also looked at identifying keywords in profile blurbs to do the matching too, but I am struggling to see how this could be done with relative ease.
My reason for posting this is simply to get some experienced knowledge about where to start the problem, of even some resources to look at that I may not have found yet.
If anyone could give me some advice on where to start i would be very grateful
I am develping in vb, with an sql server 2005 back-end

View 2 Replies View Related

Xp_startmail And Switching Profiles

May 13, 2002

Guys!
I'm using SQL Mail to send out Emails to Customers re: outstanding Invoices. I also use SQL Mail on the same box to send out emails to our Sales Reps with summaries of outstanding invoices. Now, I've set up multiple outlook profiles on the server. I tried using

xp_startmail @user = 'CreditControlDept'
xp_sendmail .... (to customers)
xp_stopmail @user = 'CreditControlDept'
xp_startmail @user = 'InvoiceTracker'
xp_sendmail...(to internal sales reps)
xp_stopmail @user = 'InvoiceTracker'

DOES NOT WORK!!! the profile does'nt switch at all. SQL Mail sends out all the emails using the profile that it started with. How can I use xp_startmail and xp_stopmail to switch between different user profiles.

Regards
Uday

View 1 Replies View Related

Unable To Get MAPI Profiles

Jan 22, 2008

Error message "Unable to get MAPI profiles" in send mail task(DTS).

View 4 Replies View Related

How To Find Matching Profiles?

May 6, 2006

Users have to answer 17 simple yes/no questions and the answers are stored in an column for each question as tinyint 0/1 values.

At least that's what seems reasonable to me at the moment.

The table is under my control so I could change it if needed.

Now from several tenthousend or maybe hundreds of thousends of entries I need to find those with the closest match. Of course, I need all of the entries that have the exact same answers and this is no problem. But - at least if there are not enough full matches - then I need all records that have maybe 16,15,14... matches out of the 17 answers.

I have not yet the idea on how to handle this without quering 17*16 different answer schemes.

View 7 Replies View Related

Can We Use SQLServer 2000 For ASP.NET Profiles And Aspnetdb ?

May 16, 2006

Hi,Can we use SQL Server 2000 for ASP.NET Profiles, Security etc.. ?for ASP.NET2.x?instead of SQL Server 2005 or Express editions?Rizwan

View 1 Replies View Related

Which Is Better? Storing Data In The Database OR Storing It In The File System

Dec 29, 2006

Hello there,I just want to ask if storing data in dbase is much better than storing it in the file system? Because for one, i am currenlty developing my thesis which uploads a blob.doc file to a web server (currently i'm using the localhost of ASP.NET) then retrieves it from the local hostAlso i want to know if im right at this, the localhost of ASP.NET is the same as the one of a natural web server on the net? Because i'm just thinking of uploading and downloading the files from a web server. Although our thesis defense didn't require us to really upload it on the net, we were advised to use a localhost on our PC's. I'll be just using my local server Is it ok to just use a web server for storing files than a database?    

View 6 Replies View Related

Storing Files In SQLServer 2005 Express

Feb 16, 2008

Hello,I'm looking for a tutorial or some sample code to save a file in sql server with c#. So far I have not been able to find a anything I could use as most tutorials are in VB. I'm using the varbinary max type to store the file. The part I need help with is selecting the file and converting it using the Stream object, not the SQL insert statements.  Thanks,Arnold 

View 3 Replies View Related

Storing Files In Image Columns In 2005

Jul 10, 2006

I did some quick Googling and didn't find the article of my dreams here. Any experience with storing files in the db in 2005? Any opinions?

Here's the deal. We have our new 'Enterprise' software being designed and written in St. Petersburg (not FL) and I'm reviewing the design for dealing with letters and forms that are generated as hard copy from our business (by the thousands per month) and sent to clients for review, signature etc. Then they are returned by fax or snail mail.

The current design has all of these being stored in image data type columns in the database--storing saved files of the actual outgoing stuff and saved files of the stuff that comes in (scanned copies or the files from our fax server).

This screams 'BAD IDEA' based on our experience doing this in SQL Server 2000. We get things like 23 page faxes from Dr's offices, large packets of FMLA forms returned, etc. In 2000 they tended to get rather large when stored in the DB and caused us all kinds of headaches when Microsoft changed how it recognized and displayed certain types of files, e.g. tiffs.

Further, the outgoing stuff is largely boilerplate with added fields from the db--name, address, a few dates. My proposed design for outbound notifications and forms was to keep only references to the template used, the date created, and an id to link it to the personal info of the schmoe to whom it was sent--essentially, store which document template and then just enough data to map to the variable content that is pulled from the db. Then you can recreate the file that was printed and mailed at any time in the future, but you don't actually save the .doc (or Word .xml) anywhere, not in the file system, not in the db.

The current developers feel this is way too much work to design--and it is certainly more effort than just generating .docs/.xml files via a merge with Word and then stuffing those into the database. They also argue that having them in the db makes them 'more secure' and more 'accessible' to users around the globe.

Does anyone know if the image storage is any better in 2005 than 2000? The .docs & .tifs we used to store just about tripled in size when we put them in the db in 2000. Plus there were the defrag issues and generally it was an unsatisfying experience.

Does anyone know what the advantages/disadvantages of generating Word .xml files might be? Can they be stored as xml data type in SQL Server? Perhaps this is a better option?

If anyone has the time to digest this, please send opinions.

Thanks!

View 3 Replies View Related

Storing Bulk Data From Dataset To Sql Mobile 2005 Using C#

Apr 3, 2006

hi,

I have developed an application in c#.net 2.0 for Pocket PC. And even i developed a webservice to communicate between sql server 2005 and sql mobile 2005. Webservice returns the data in a dataset format from sql server 2005, but while inserting the data row by row from dataset, it is taking a huge amount of time. I would like to know, is there any way where i can copy the bulk data from dataset into the sql mobile 2005 using c#.And how this can be achieved.

Thank you

View 5 Replies View Related

Caching (storing) Calculated Members In Analysis Services 2005

Mar 2, 2006

Do anybody know if Analysis Services 2005 allows cashing (storing) calculated members ?

There is a cube in Analysis Services 2000 with a calculated member based on some running sums. The performance of MDXs is too slow because running summs are being recalculated for each member of time dimension on each call.

I think that caching calculated members might help me and hope that this feature exists in Analysis Services 2005 .

Thanks!

View 1 Replies View Related

SQL Server Storing As �

Oct 20, 2004

My forms are taking user input, then HtmlEncoding them prior to being stored in the SQL DB. For some reason, SQL is storing quotes as � and it is causing the HTML when decoded in the page to not be rendered properly.

Has anyone come across this issue before?

For example (without encoding for readability):

SQL should store the parsed string as: <a href="someurl" class="main">

but for some reason it's being stored as: <a href=�someurl� class=�main�>.

Thoughts?

View 2 Replies View Related

Storing Articles In SQL Server

Oct 25, 2007

Hello Everyonen and thanks for your help in advance.  I am developing a conetnet management system to allow for the storage of articles within a SQL Server 2000 database.  I am using FreeTextBox as the editor for users to enter articles.  I ahve two questions.  First, many of the articles are quite lengthy and including HTML formatting go well beyond 8000 characters.  How should I go about storing these articles?  Should I use a TEXT datatype, or perhaps split the data into more than one row.  This leads to my second quuestion.  Many sites that display article type data break the artilce into multiple pages with page numbers or next links to page back and forth.  I am not sure hot to go about implmeneting this.  Any help on this topic would be greatly appreciated.  Thanks.

View 3 Replies View Related

Storing Session In SQL Server

Oct 4, 2004

I have some C# code that iterates through the session state, serializes each object and stores the binary representation in an SQL table with an 'image' column. The problem is: it doesn't work. SQL server doesn't throw an error (at least ADO.NET doesnt propagate it); the table is just left unchanged. The SP works (I tested it with a few simple values); the MemoryStream and byte array are being populated correctly and bound to the parameter correctly.

What am I doing wrong? Anyone have a better approach? I know there is a builtin way of storing state in an SQL server, but I only need to do this once--namely, when a user is redirected from non-secure to secure pages--so I don't want to take that performance hit,


string uid = _session.SessionID;
object toSerialize;
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream stream;

SqlConnection dbConn = SupportClasses.SqlUtilities.DBConn();
SqlCommand cmd;
SqlTransaction storeSession = null;
SqlParameter uidParam, keyParam, objParam;
try
{
dbConn.Open();
storeSession = dbConn.BeginTransaction();
foreach (string key in _session.Keys)
{
toSerialize = _session[ key ];
stream = new MemoryStream();
formatter.Serialize(stream, toSerialize);

cmd = new SqlCommand("store_session_object", dbConn, storeSession);
cmd.CommandType = CommandType.StoredProcedure;
uidParam = new SqlParameter("@uid", SqlDbType.VarChar);
uidParam.Value = uid;
cmd.Parameters.Add(uidParam);
keyParam = new SqlParameter("@object_key", SqlDbType.VarChar);
keyParam.Value = key;
cmd.Parameters.Add(keyParam);
objParam = new SqlParameter("@data", SqlDbType.Image);
objParam.Value = stream.ToArray();
cmd.Parameters.Add(objParam);

cmd.ExecuteNonQuery();
}
}
catch (SqlException ex)
{
SupportClasses.ErrorHandler.HandleSQLError(ex);
storeSession.Rollback();
}
catch (System.Runtime.Serialization.SerializationException exs)
{
// do something
}
finally
{
dbConn.Close();
}


For those interested, here is the code for the SP:

CREATE PROCEDURE store_session_object
@uid varchar(50),
@object_key varchar(25),
@data image
AS
INSERT INTO session_hold (uid, object_key, object)
VALUES (@uid, @object_key, @data)


[Cross-posted because issue spans several topics.]

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved