Showing posts with label asp. Show all posts
Showing posts with label asp. Show all posts

Wednesday, March 28, 2012

how to transform an .MDF database into a permanent database in sql server express?

Hi, i have a MDF file used by an asp.net application (with sql server 2005 express).

I want to make it to a permanent database in sql server express.

I know that i can attach it from Management Studio, but is there no better way?

Does it exist a way to 'import' or 'migrate' or copy' a .MDF.database into the central sql server, as if created directly in sql server express? After that, i can delete the .MDF file.

Thanks

Tartuffe

Hello,

if you would create a new database with SQL Server, it will also create an .mdf-file. You can see this for yourself in the following location:

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data

So, I'm not sure what your problem is with the mdf files, but they are perfectly normal SQL Database files and attaching is therefore a good way to bring your database online. If you want, you can first also create a brand new database first, and then import the date. In Management Studio you can right click the new database in the Object Explorer, select tasks > import data... and it should start the SQL Server Import and Export Wizard. Since it's a wizard, I think you will be able to perform the task as you see fit.

Good luck!

|||

Hi, thanks for replying.

Unfortunately, i have Management Studio express and when rightclicking on the new created db, i can't see Import, only backup/restore shrink ...

|||

Hi tartuffe2,

I my opinion, using attach database is the best way for this scenario.

SQL Server 2005 has many ways to implement move, copy, and update database, such as detach/attach, backup/restore, import/export, database mirroring, log shipping, replication. But some of them do not support in Express Edition. For your request, attach is the fastest and simplest way.

Thanks.

How to transfer binary data from Server side to the client side through ASP Page ?

Hi,
I am designing a 4-tier application. It is like this.
Client - Business Logic Client Side (UI Validation) - ASP Page - Business
Logic Server Side (Database related) - SQL server database.
In this scenario, As of now I am passing a XML string from Server side
(Using ADO 2.6) to the client side through ASP. But I believe, compared to
transfer of huge XML strings from the server side to the client side,
transfer of binary data would be fast.
Can any one tell me, how to transfer binary data from Server side to the
client side through ASP Page ?
Thanks and Regards,
Peri
"Peri" <lperi@.CSPL.com> wrote in message
news:u4SyKPxPEHA.3220@.TK2MSFTNGP09.phx.gbl...
[snip]
> Can any one tell me, how to transfer binary data from Server side to the
> client side through ASP Page ?
You would need to figure out what the binary data would look like and how to
transfer it. That is the beauty of XML, you don't have to do either (but you
do pay the package tax).
Bryant

Friday, March 23, 2012

how to test before putting in production

Hi all,
I have a asp .net 1.1 application running on the intranet which uses SQL Server 2000.
The application is in production and everytime I want to do some changes, i do the changes on my
development machine then I copy the application dll on the server.
The problem is that I'm using Stored Procedures for all my Select, Insert and Delete statements.
These stored procedures are live on the server so I can't do the modifications locally and test them then copy to the server.

How can I do modifications without affecting the production server and the users ?
thanks.

The simplest solution is to have a local copy of your database and test against that. You can download the MSDE from Microsoft for free.

A more complicated solution would be to create the test SPs in a different schema from dbo, and reference them that way. (I've had good luck doing that with Oracle using synonyms. Everything was referenced via synonym, and if a developer wanted to override the object, he'd create a new one with the same name as the synonym in his own schema. I'm not sure how well this would work in SQL Server.)

|||Thanks for your reply. As you said the first solution seems easier.

I still have a few questions if you don't mind:
When I download MSDE, do they have utilities to copy my whole database from SQL server to MSDE ?|||

I use enterprise manager to back up the production DB, and then restore it on MSDE.

Yes. Just change the connection string to point to the appropriate db. It you have it in your web.config, it should be easy to do.

You can do a simple copy/paste. I use SqlDiff to copy schema/procedure changes from one database to another.

|||thank you , seems good i'll try that.

Wednesday, March 21, 2012

How to tell if there is something in a binary field

I tried to upload a pdf file into a binary field using asp upload. I
cannot tell if there is anything in the field using query analyzer, and I wa
s
wondering what shows in the grid when something exists there. It is just
showing as <binary>Don't use a grid for this kind of thing.
SELECT DATALENGTH(col) FROM Table
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Linda Lalewicz" <LindaLalewicz@.discussions.microsoft.com> wrote in message
news:3208A836-96ED-406C-BF8A-305946E6BFE7@.microsoft.com...
>I tried to upload a pdf file into a binary field using asp upload. I
> cannot tell if there is anything in the field using query analyzer, and I
> was
> wondering what shows in the grid when something exists there. It is just
> showing as <binary>|||I also found that a select for that field would return something if there wa
s
something in there, if not it came back null.
Now I need to figure out why the clues that you gave me yesterday don't seem
to show me my pdf file. I just see a blank page with no errors, no pdf. :
(
wahhhh
"Aaron [SQL Server MVP]" wrote:

> Don't use a grid for this kind of thing.
> SELECT DATALENGTH(col) FROM Table
> --
> This is my signature. It is a general reminder.
> Please post DDL, sample data and desired results.
> See http://www.aspfaq.com/5006 for info.
>
>
> "Linda Lalewicz" <LindaLalewicz@.discussions.microsoft.com> wrote in messag
e
> news:3208A836-96ED-406C-BF8A-305946E6BFE7@.microsoft.com...
>
>sql

Wednesday, March 7, 2012

How to store Resume and cover letter into SQL Server?

Hi,

I am trying to create an asp.net web recruiting application for HR, which will give the users the ability to both copy/paste the Resume and cover letter in textbox and upload resume and cover letter, then submit it (which will be saved into SQL Server 2000 table).

I am thinking to save Resume and cover_letter as Image data type columns in SQL Server.

. Can someone give me a direction about how to save the uploaded resume and cover letter to table and if it's the easiest way to do it?

. What to deal with different formats of uploaded resumes? I hope to limit to only Word or HTML

. Since I also give user another option - copy/paste the resume and coverletter into a textboxes. Can I simply save the copy/paste resume and cover letter into text field column? Later, say, if any HR recruiter retrieve the text from database, will it concatonates everything together without line break?

Any ideas is appreciated.

You have two options use NChar 4000 or NVarchar 4000 and limit the size of the uploaded file so you can use ANSI SQL %Like% in your search or use NText and use Full Text index which is an add on to SQL Server dependent on Microsoft Search service with the Microsoft Catalog populated all the time to get search results. Full Text index uses Microsoft proprietry key word search as CONTAINS, CONTAINSTABLE, FREETEXT and FREETEXTTABLE. Run a search for Full Text index implementation in SQL Server BOL(books online) Hope this helps.|||

You can save the resume in the database in an image field

//Create a Buffer Stream to Hold the uploaded file
string FileName = GetFileName(txtFileUpload.PostedFile.FileName.ToString());
string FileType = txtFileUpload.PostedFile.ContentType.ToString();
int FileSize = int.Parse(txtFileUpload.PostedFile.ContentLength.ToString());
byte[] DocBuffer = new byte[FileSize];
Stream objSream;
objSream = txtFileUpload.PostedFile.InputStream;
objSream.Read(DocBuffer,0,FileSize);
//Pass this buffer as a paramter to a Stored procedure which will insert a new record into ur table
SqlParameter pcvContent = new SqlParameter("@.cvContent",SqlDbType.Image);
pcvContent.Direction = ParameterDirection.Input;
pcvContent.Value = cvContent;
dbCommand.Parameters.Add(pcvContent);
//======================================================================
to retrive the saved file from the database you have to do the following
do your select statment
Response.AddHeader("Content-Disposition","attachment; filename='"+ dr["FileName"].ToString() +"'");
Response.ContentType = dr["FileType"].ToString();
Response.BinaryWrite( (byte[]) dr["CvContent"]);
//=========================================================================
this the first solution.
The secound one is to create a resume builder.

|||Personally, I would consider storing BOTH the raw document in an IMAGEcolumn, and ripping the text of the document and storing that in a TEXTcolumn. This will allow you to set up a full-text index forsearching the resumes, while at the same time making it easy for usersto get the resumes back in whatever format they were submitted in.

|||

hi,

I need to do a keyword search in word and pdf documents. I tried using Index Server linked with SQL Server but its giving me many problems. So i'm planning to rip off the text from the word or pdf docs and store the text in a TEXT field as u said in one of the threads so that i can do a search easily.

Is it possible to read from a word or a pdf file and store it in a string. Sorry about contacting u directly

Thanks in Advance

Friday, February 24, 2012

How to store HTML code in SQL server table

Hello,
I'm creating something like a web site builder in ASP.Net, and I need to
store an HTML code in the SQL server table. If my customer just enters an
HTML code, it is stored in the SQL server table like this: <table
cellSpacing="0" cellPadding="0" width="760"
border="0">, instead of <table cellSpacing="0" cellPadding="0"
width="760" border="0">
This significantly increases the size of the stored code.
Are there any conversion functions or something like this to avoid it? Where
this conversion should be done - in ASP.Net or SQL server? How do I convert
it back to create an HTML page?
Please note that I must use the Unicode data type - ntext, nchar etc, since
I'm using some Cyrillic characters.
I would appreciate your advice very much.
Thank you,
Peter Afonin
Peter,
ntext in SQL Server will store Html markup just fine. You are encoding
your html before storing it in the database. Find out where you are
encoding the markup and change that code. Debug your code and make sure
that you are indeed sending pure html to the database. SQL Server will not
automatically encode html, so your code is doing it somewhere.
Best regards,
Jeffrey Palermo
"Peter Afonin" <pva@.speakeasy.net> wrote in message
news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I'm creating something like a web site builder in ASP.Net, and I need to
> store an HTML code in the SQL server table. If my customer just enters an
> HTML code, it is stored in the SQL server table like this: <table
> cellSpacing="0" cellPadding="0" width="760"
> border="0">, instead of <table cellSpacing="0"
cellPadding="0"
> width="760" border="0">
> This significantly increases the size of the stored code.
> Are there any conversion functions or something like this to avoid it?
Where
> this conversion should be done - in ASP.Net or SQL server? How do I
convert
> it back to create an HTML page?
> Please note that I must use the Unicode data type - ntext, nchar etc,
since
> I'm using some Cyrillic characters.
> I would appreciate your advice very much.
> Thank you,
> --
> Peter Afonin
>
|||What is the code you use to store the string you get in the SQL database?
"Peter Afonin" <pva@.speakeasy.net> a crit dans le message de
news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I'm creating something like a web site builder in ASP.Net, and I need to
> store an HTML code in the SQL server table. If my customer just enters an
> HTML code, it is stored in the SQL server table like this: <table
> cellSpacing="0" cellPadding="0" width="760"
> border="0">, instead of <table cellSpacing="0"
cellPadding="0"
> width="760" border="0">
> This significantly increases the size of the stored code.
> Are there any conversion functions or something like this to avoid it?
Where
> this conversion should be done - in ASP.Net or SQL server? How do I
convert
> it back to create an HTML page?
> Please note that I must use the Unicode data type - ntext, nchar etc,
since
> I'm using some Cyrillic characters.
> I would appreciate your advice very much.
> Thank you,
> --
> Peter Afonin
>
>
|||As the other poster states, it is not SQL that is doing the encoding, it is
something else...
Also, if the html pages will be less than 4000 unicode characters, you may
prefer to strore the data in a varchar column.
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Peter Afonin" <pva@.speakeasy.net> wrote in message
news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I'm creating something like a web site builder in ASP.Net, and I need to
> store an HTML code in the SQL server table. If my customer just enters an
> HTML code, it is stored in the SQL server table like this: <table
> cellSpacing="0" cellPadding="0" width="760"
> border="0">, instead of <table cellSpacing="0"
cellPadding="0"
> width="760" border="0">
> This significantly increases the size of the stored code.
> Are there any conversion functions or something like this to avoid it?
Where
> this conversion should be done - in ASP.Net or SQL server? How do I
convert
> it back to create an HTML page?
> Please note that I must use the Unicode data type - ntext, nchar etc,
since
> I'm using some Cyrillic characters.
> I would appreciate your advice very much.
> Thank you,
> --
> Peter Afonin
>
|||Thank you everyone for your suggestions.
So far when I use ntext it works OK, then I use the Literal control and
Server.Decode to write the data in ASP.Net.
Peter
"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:eL$4fPh1EHA.4004@.tk2msftngp13.phx.gbl...
> As the other poster states, it is not SQL that is doing the encoding, it
is[vbcol=seagreen]
> something else...
> Also, if the html pages will be less than 4000 unicode characters, you may
> prefer to strore the data in a varchar column.
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Peter Afonin" <pva@.speakeasy.net> wrote in message
> news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
an[vbcol=seagreen]
width="760"
> cellPadding="0"
> Where
> convert
> since
>
|||Wayne,
Maybe it's just a typo, but varchar cannot be properly used with unicode
and has a maximum length of 8000 characters. nvarchar has a limit of 4000
characters and should be used for all applications for maintenance purposes
(since most applications will have to support unicode in the future).
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:eL$4fPh1EHA.4004@.tk2msftngp13.phx.gbl...
> As the other poster states, it is not SQL that is doing the encoding, it
is[vbcol=seagreen]
> something else...
> Also, if the html pages will be less than 4000 unicode characters, you may
> prefer to strore the data in a varchar column.
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Peter Afonin" <pva@.speakeasy.net> wrote in message
> news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
an[vbcol=seagreen]
width="760"
> cellPadding="0"
> Where
> convert
> since
>
|||Peter, I'm glad you have it working now.
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Peter Afonin" <peter@.gudzon.net> wrote in message
news:OAMi7Mk1EHA.1124@.tk2msftngp13.phx.gbl...[vbcol=seagreen]
> Thank you everyone for your suggestions.
> So far when I use ntext it works OK, then I use the Literal control and
> Server.Decode to write the data in ASP.Net.
> Peter
> "Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
> news:eL$4fPh1EHA.4004@.tk2msftngp13.phx.gbl...
> is
may[vbcol=seagreen]
to
> an
> width="760"
>

How to store HTML code in SQL server table

Hello,
I'm creating something like a web site builder in ASP.Net, and I need to
store an HTML code in the SQL server table. If my customer just enters an
HTML code, it is stored in the SQL server table like this: <table
cellSpacing="0" cellPadding="0" width="760"
border="0">, instead of <table cellSpacing="0" cellPadding="0"
width="760" border="0">
This significantly increases the size of the stored code.
Are there any conversion functions or something like this to avoid it? Where
this conversion should be done - in ASP.Net or SQL server? How do I convert
it back to create an HTML page?
Please note that I must use the Unicode data type - ntext, nchar etc, since
I'm using some Cyrillic characters.
I would appreciate your advice very much.
Thank you,
Peter AfoninPeter,
ntext in SQL Server will store Html markup just fine. You are encoding
your html before storing it in the database. Find out where you are
encoding the markup and change that code. Debug your code and make sure
that you are indeed sending pure html to the database. SQL Server will not
automatically encode html, so your code is doing it somewhere.
Best regards,
Jeffrey Palermo
"Peter Afonin" <pva@.speakeasy.net> wrote in message
news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I'm creating something like a web site builder in ASP.Net, and I need to
> store an HTML code in the SQL server table. If my customer just enters an
> HTML code, it is stored in the SQL server table like this: <table
> cellSpacing="0" cellPadding="0" width="760"
> border="0">, instead of <table cellSpacing="0"
cellPadding="0"
> width="760" border="0">
> This significantly increases the size of the stored code.
> Are there any conversion functions or something like this to avoid it?
Where
> this conversion should be done - in ASP.Net or SQL server? How do I
convert
> it back to create an HTML page?
> Please note that I must use the Unicode data type - ntext, nchar etc,
since
> I'm using some Cyrillic characters.
> I would appreciate your advice very much.
> Thank you,
> --
> Peter Afonin
>|||What is the code you use to store the string you get in the SQL database?
"Peter Afonin" <pva@.speakeasy.net> a crit dans le message de
news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I'm creating something like a web site builder in ASP.Net, and I need to
> store an HTML code in the SQL server table. If my customer just enters an
> HTML code, it is stored in the SQL server table like this: <table
> cellSpacing="0" cellPadding="0" width="760"
> border="0">, instead of <table cellSpacing="0"
cellPadding="0"
> width="760" border="0">
> This significantly increases the size of the stored code.
> Are there any conversion functions or something like this to avoid it?
Where
> this conversion should be done - in ASP.Net or SQL server? How do I
convert
> it back to create an HTML page?
> Please note that I must use the Unicode data type - ntext, nchar etc,
since
> I'm using some Cyrillic characters.
> I would appreciate your advice very much.
> Thank you,
> --
> Peter Afonin
>
>|||As the other poster states, it is not SQL that is doing the encoding, it is
something else...
Also, if the html pages will be less than 4000 unicode characters, you may
prefer to strore the data in a varchar column.
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Peter Afonin" <pva@.speakeasy.net> wrote in message
news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I'm creating something like a web site builder in ASP.Net, and I need to
> store an HTML code in the SQL server table. If my customer just enters an
> HTML code, it is stored in the SQL server table like this: <table
> cellSpacing="0" cellPadding="0" width="760"
> border="0">, instead of <table cellSpacing="0"
cellPadding="0"
> width="760" border="0">
> This significantly increases the size of the stored code.
> Are there any conversion functions or something like this to avoid it?
Where
> this conversion should be done - in ASP.Net or SQL server? How do I
convert
> it back to create an HTML page?
> Please note that I must use the Unicode data type - ntext, nchar etc,
since
> I'm using some Cyrillic characters.
> I would appreciate your advice very much.
> Thank you,
> --
> Peter Afonin
>|||Thank you everyone for your suggestions.
So far when I use ntext it works OK, then I use the Literal control and
Server.Decode to write the data in ASP.Net.
Peter
"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:eL$4fPh1EHA.4004@.tk2msftngp13.phx.gbl...
> As the other poster states, it is not SQL that is doing the encoding, it
is
> something else...
> Also, if the html pages will be less than 4000 unicode characters, you may
> prefer to strore the data in a varchar column.
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Peter Afonin" <pva@.speakeasy.net> wrote in message
> news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
an[vbcol=seagreen]
width="760"[vbcol=seagreen]
> cellPadding="0"
> Where
> convert
> since
>|||Wayne,
Maybe it's just a typo, but varchar cannot be properly used with unicode
and has a maximum length of 8000 characters. nvarchar has a limit of 4000
characters and should be used for all applications for maintenance purposes
(since most applications will have to support unicode in the future).
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:eL$4fPh1EHA.4004@.tk2msftngp13.phx.gbl...
> As the other poster states, it is not SQL that is doing the encoding, it
is
> something else...
> Also, if the html pages will be less than 4000 unicode characters, you may
> prefer to strore the data in a varchar column.
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Peter Afonin" <pva@.speakeasy.net> wrote in message
> news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
an[vbcol=seagreen]
width="760"[vbcol=seagreen]
> cellPadding="0"
> Where
> convert
> since
>|||Peter, I'm glad you have it working now.
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Peter Afonin" <peter@.gudzon.net> wrote in message
news:OAMi7Mk1EHA.1124@.tk2msftngp13.phx.gbl...
> Thank you everyone for your suggestions.
> So far when I use ntext it works OK, then I use the Literal control and
> Server.Decode to write the data in ASP.Net.
> Peter
> "Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
> news:eL$4fPh1EHA.4004@.tk2msftngp13.phx.gbl...
> is
may[vbcol=seagreen]
to[vbcol=seagreen]
> an
> width="760"
>

How to store HTML code in SQL server table

Hello,
I'm creating something like a web site builder in ASP.Net, and I need to
store an HTML code in the SQL server table. If my customer just enters an
HTML code, it is stored in the SQL server table like this: <table
cellSpacing="0" cellPadding="0" width="760"
border="0">, instead of <table cellSpacing="0" cellPadding="0"
width="760" border="0">
This significantly increases the size of the stored code.
Are there any conversion functions or something like this to avoid it? Where
this conversion should be done - in ASP.Net or SQL server? How do I convert
it back to create an HTML page?
Please note that I must use the Unicode data type - ntext, nchar etc, since
I'm using some Cyrillic characters.
I would appreciate your advice very much.
Thank you,
--
Peter AfoninPeter,
ntext in SQL Server will store Html markup just fine. You are encoding
your html before storing it in the database. Find out where you are
encoding the markup and change that code. Debug your code and make sure
that you are indeed sending pure html to the database. SQL Server will not
automatically encode html, so your code is doing it somewhere.
Best regards,
Jeffrey Palermo
"Peter Afonin" <pva@.speakeasy.net> wrote in message
news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I'm creating something like a web site builder in ASP.Net, and I need to
> store an HTML code in the SQL server table. If my customer just enters an
> HTML code, it is stored in the SQL server table like this: <table
> cellSpacing="0" cellPadding="0" width="760"
> border="0">, instead of <table cellSpacing="0"
cellPadding="0"
> width="760" border="0">
> This significantly increases the size of the stored code.
> Are there any conversion functions or something like this to avoid it?
Where
> this conversion should be done - in ASP.Net or SQL server? How do I
convert
> it back to create an HTML page?
> Please note that I must use the Unicode data type - ntext, nchar etc,
since
> I'm using some Cyrillic characters.
> I would appreciate your advice very much.
> Thank you,
> --
> Peter Afonin
>|||What is the code you use to store the string you get in the SQL database?
"Peter Afonin" <pva@.speakeasy.net> a écrit dans le message de
news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I'm creating something like a web site builder in ASP.Net, and I need to
> store an HTML code in the SQL server table. If my customer just enters an
> HTML code, it is stored in the SQL server table like this: <table
> cellSpacing="0" cellPadding="0" width="760"
> border="0">, instead of <table cellSpacing="0"
cellPadding="0"
> width="760" border="0">
> This significantly increases the size of the stored code.
> Are there any conversion functions or something like this to avoid it?
Where
> this conversion should be done - in ASP.Net or SQL server? How do I
convert
> it back to create an HTML page?
> Please note that I must use the Unicode data type - ntext, nchar etc,
since
> I'm using some Cyrillic characters.
> I would appreciate your advice very much.
> Thank you,
> --
> Peter Afonin
>
>|||As the other poster states, it is not SQL that is doing the encoding, it is
something else...
Also, if the html pages will be less than 4000 unicode characters, you may
prefer to strore the data in a varchar column.
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Peter Afonin" <pva@.speakeasy.net> wrote in message
news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> Hello,
> I'm creating something like a web site builder in ASP.Net, and I need to
> store an HTML code in the SQL server table. If my customer just enters an
> HTML code, it is stored in the SQL server table like this: <table
> cellSpacing="0" cellPadding="0" width="760"
> border="0">, instead of <table cellSpacing="0"
cellPadding="0"
> width="760" border="0">
> This significantly increases the size of the stored code.
> Are there any conversion functions or something like this to avoid it?
Where
> this conversion should be done - in ASP.Net or SQL server? How do I
convert
> it back to create an HTML page?
> Please note that I must use the Unicode data type - ntext, nchar etc,
since
> I'm using some Cyrillic characters.
> I would appreciate your advice very much.
> Thank you,
> --
> Peter Afonin
>|||Thank you everyone for your suggestions.
So far when I use ntext it works OK, then I use the Literal control and
Server.Decode to write the data in ASP.Net.
Peter
"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:eL$4fPh1EHA.4004@.tk2msftngp13.phx.gbl...
> As the other poster states, it is not SQL that is doing the encoding, it
is
> something else...
> Also, if the html pages will be less than 4000 unicode characters, you may
> prefer to strore the data in a varchar column.
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Peter Afonin" <pva@.speakeasy.net> wrote in message
> news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> > Hello,
> >
> > I'm creating something like a web site builder in ASP.Net, and I need to
> > store an HTML code in the SQL server table. If my customer just enters
an
> > HTML code, it is stored in the SQL server table like this: <table
> > cellSpacing="0" cellPadding="0"
width="760"
> > border="0">, instead of <table cellSpacing="0"
> cellPadding="0"
> > width="760" border="0">
> >
> > This significantly increases the size of the stored code.
> >
> > Are there any conversion functions or something like this to avoid it?
> Where
> > this conversion should be done - in ASP.Net or SQL server? How do I
> convert
> > it back to create an HTML page?
> >
> > Please note that I must use the Unicode data type - ntext, nchar etc,
> since
> > I'm using some Cyrillic characters.
> >
> > I would appreciate your advice very much.
> >
> > Thank you,
> >
> > --
> > Peter Afonin
> >
> >
>|||Wayne,
Maybe it's just a typo, but varchar cannot be properly used with unicode
and has a maximum length of 8000 characters. nvarchar has a limit of 4000
characters and should be used for all applications for maintenance purposes
(since most applications will have to support unicode in the future).
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:eL$4fPh1EHA.4004@.tk2msftngp13.phx.gbl...
> As the other poster states, it is not SQL that is doing the encoding, it
is
> something else...
> Also, if the html pages will be less than 4000 unicode characters, you may
> prefer to strore the data in a varchar column.
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Peter Afonin" <pva@.speakeasy.net> wrote in message
> news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> > Hello,
> >
> > I'm creating something like a web site builder in ASP.Net, and I need to
> > store an HTML code in the SQL server table. If my customer just enters
an
> > HTML code, it is stored in the SQL server table like this: <table
> > cellSpacing="0" cellPadding="0"
width="760"
> > border="0">, instead of <table cellSpacing="0"
> cellPadding="0"
> > width="760" border="0">
> >
> > This significantly increases the size of the stored code.
> >
> > Are there any conversion functions or something like this to avoid it?
> Where
> > this conversion should be done - in ASP.Net or SQL server? How do I
> convert
> > it back to create an HTML page?
> >
> > Please note that I must use the Unicode data type - ntext, nchar etc,
> since
> > I'm using some Cyrillic characters.
> >
> > I would appreciate your advice very much.
> >
> > Thank you,
> >
> > --
> > Peter Afonin
> >
> >
>|||Peter, I'm glad you have it working now.
--
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Peter Afonin" <peter@.gudzon.net> wrote in message
news:OAMi7Mk1EHA.1124@.tk2msftngp13.phx.gbl...
> Thank you everyone for your suggestions.
> So far when I use ntext it works OK, then I use the Literal control and
> Server.Decode to write the data in ASP.Net.
> Peter
> "Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
> news:eL$4fPh1EHA.4004@.tk2msftngp13.phx.gbl...
> > As the other poster states, it is not SQL that is doing the encoding, it
> is
> > something else...
> >
> > Also, if the html pages will be less than 4000 unicode characters, you
may
> > prefer to strore the data in a varchar column.
> >
> > --
> > Wayne Snyder, MCDBA, SQL Server MVP
> > Mariner, Charlotte, NC
> > www.mariner-usa.com
> > (Please respond only to the newsgroups.)
> >
> > I support the Professional Association of SQL Server (PASS) and it's
> > community of SQL Server professionals.
> > www.sqlpass.org
> >
> > "Peter Afonin" <pva@.speakeasy.net> wrote in message
> > news:eyXuQOa1EHA.3820@.TK2MSFTNGP11.phx.gbl...
> > > Hello,
> > >
> > > I'm creating something like a web site builder in ASP.Net, and I need
to
> > > store an HTML code in the SQL server table. If my customer just enters
> an
> > > HTML code, it is stored in the SQL server table like this: <table
> > > cellSpacing="0" cellPadding="0"
> width="760"
> > > border="0">, instead of <table cellSpacing="0"
> > cellPadding="0"
> > > width="760" border="0">
> > >
> > > This significantly increases the size of the stored code.
> > >
> > > Are there any conversion functions or something like this to avoid it?
> > Where
> > > this conversion should be done - in ASP.Net or SQL server? How do I
> > convert
> > > it back to create an HTML page?
> > >
> > > Please note that I must use the Unicode data type - ntext, nchar etc,
> > since
> > > I'm using some Cyrillic characters.
> > >
> > > I would appreciate your advice very much.
> > >
> > > Thank you,
> > >
> > > --
> > > Peter Afonin
> > >
> > >
> >
> >
>

how to store encrypted data in sql database

hai everybody,

I have a login page in asp.net with the details being stored in the database. In the table at present i am storing the password in plain text field.

Is there any possible for me to store the data in any encrypted format or some format so that no one will be able to view the password.

And while returning back to the webpage i want them in the plain text . . . !

Is there any possibility for this

kindly help at the earliest

thanks in advance

sasidar::Is there any possibility for this

Sure. Just encrypt the data before writing it into the server, decrypt it after reading it.

note, though, that what you do here is NOT safe. Why do you ever want to decrypt the password? Use a hash and compare the hashed values.|||The best solution is to use a one way hash created in ASP.NET code, and then whenever you want to check the entered password you create a hashed copy of the password entered, and then compare it to the hash stored in the database.


private string CreatePasswordHash(string pwd,string salt)
{
string saltAndPwd=string.Concat(pwd,salt);
string hashedPwd=FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPwd,"SHA1");
return hashedPwd;
}

The salt string is just a string used to ensure that each password when encrypted will be unique (so if two people have a password of "password" the hashes will not be the same.

This way, really no one, not even you as the administrator of teh system, will be able to read the password (this is a good thing). You can of course create a method to reset the password.|||Steve Wyncoop of theSQL Server Worldwide User's Group is ga-ga overXP_CRYPT. I've not used the product, but it looks like it simplifies saving encrypted data to SQL Server.

Don|||Thanks for those who replied me,

But there is one more doubt for me. If i am using the hashing technique then we cannot reveal the password in the plain text format. Suppose if there is a situation where i require the password to known how to get back the plain text format. ?

Through my readings i came to conclusion that it cannot be done. Is it So ? In that case is there any other technique so that i can encrypt the password and then decrypt the password whenever required

Awaiting for the solutions :

Thanks in advance

Sasidar|||You should work out a way that you never need to get to the decrypted password. People often use the same password for lots of things. If a user uses their one password on your site, it is better that even you never be able to get to that password.

In systems I write, we have a system in place where a password can be reset, but we have no way to reverse the one way hash. This way, even if the database is compromised, user's passwords will not be exposed. Your users will appreciate it.|||Thanks for ur reply ,

but still i have a doubt , say suppose my client or user forget his pasword , then what should i do so that i can change the password . If i am going to change contecnts directly into the database then the plain text will be changed and i hope that will not be fine. Is there any solution for this

Awaiting for the solution

Thanks

Bye

Sasidar|||The way tou handle that is to create an administrative page that allows you to reset the password (you have a page that encrypts a default password EXACTLY the same way that your normal password hashing works).|||sorry mr.douglas

i am not able to understand

can u give me more details please

Thanking u

sasidar|||I really can't, without providing all the code to do it, and I do not have time for that.

All you need to do is do the exact same one-way hashing on a default password (for instance, "password") and save that as the users new password, and in some way notify the user of the new password.

This book:

http://www.microsoft.com/mspress/books/6501.asp

has lots of information on how to do this kind of thing.

Sunday, February 19, 2012

How to stay flexible?

I'm currently using CFMX with an SQL Server 2000. However, I'm moving to
more cost efficient solutions such as ASP.NET and some other database, which
I haven't determined yet. The database will probably be MSDE or MySQL. I
don't do many transactions, so either of those two choices should be fine.
In general, are there any rules to keeping your database very flexible?
Meaning, it won't be difficult for me to move everything from SQL Server to
MSDE. Or from MSDE to MySQL. Are there any general pointers or guidelines
that can be followed if I'm unsure how long I may stay with some particular
database vendor?
Same goes for the front end and application level logic. I don't want
either to be tied into a specific database vendor. Not sure how possible
any of these are but any comments are welcome.
Thanks,
BrettSQL Server to MSDE and back is a no-brainer. They are the same product. Goin
g to other vendors, your
best bet is to confine to ANSI SQL. Note that some vendors do not support AN
SI SQL (also, there are
different revisions of the ANSI SQL standard). Study up on the candidates an
d see what level of
compliance to the ANSI SQL standard they have.Then try to confine your code
to that.
http://www.mimer.com/ has a SQL Validator, might be worth checking out.
But be aware that you will be missing out on a lot of good stuff. Things lik
e stored procedures,
triggers, a lot of the system functions to mention a few things in SQL Serve
r which aren't ANSI SQL
compliant (and nor are Oracle's and possibly DB2's either).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Brett" <no@.spam.com> wrote in message news:%23%23ciH72PFHA.4028@.tk2msftngp13.phx.gbl...[co
lor=darkred]
> I'm currently using CFMX with an SQL Server 2000. However, I'm moving to
more cost efficient
> solutions such as ASP.NET and some other database, which I haven't determi
ned yet. The database
> will probably be MSDE or MySQL. I don't do many transactions, so either o
f those two choices
> should be fine.
> In general, are there any rules to keeping your database very flexible? Me
aning, it won't be
> difficult for me to move everything from SQL Server to MSDE. Or from MSDE
to MySQL. Are there
> any general pointers or guidelines that can be followed if I'm unsure how
long I may stay with
> some particular database vendor?
> Same goes for the front end and application level logic. I don't want eit
her to be tied into a
> specific database vendor. Not sure how possible any of these are but any
comments are welcome.
> Thanks,
> Brett
>[/color]|||There is no conversion moving from SQL to MSDE as they are essentially same
engine. However, moving from SQL Server to MySQL or any other product is a
different matter. First and foremost, it depends on what you are moving. If
you
have no stored procs, user defined functions or user defined data types, the
n
moving to anything else should not problem. The data is generally the easies
t
thing to move. It's everything other than the data that is a challenge.
Thomas
"Brett" <no@.spam.com> wrote in message
news:%23%23ciH72PFHA.4028@.tk2msftngp13.phx.gbl...
> I'm currently using CFMX with an SQL Server 2000. However, I'm moving to
more
> cost efficient solutions such as ASP.NET and some other database, which I
> haven't determined yet. The database will probably be MSDE or MySQL. I d
on't
> do many transactions, so either of those two choices should be fine.
> In general, are there any rules to keeping your database very flexible?
> Meaning, it won't be difficult for me to move everything from SQL Server t
o
> MSDE. Or from MSDE to MySQL. Are there any general pointers or guidelin
es
> that can be followed if I'm unsure how long I may stay with some particula
r
> database vendor?
> Same goes for the front end and application level logic. I don't want eit
her
> to be tied into a specific database vendor. Not sure how possible any of
> these are but any comments are welcome.
> Thanks,
> Brett
>|||MySQL Server is probably the top candidate as it is supported very widely.
MSDE isn't. If in my current application I make use of stored procedure
calls to SQL Server 2000, I suppose the best way to make the application
available for a database switch is to just put all of the database calls
into some type of encapsulation. Inside of the encapsulation will be either
a stored procedure call or a query, depending on the database. That sound
right?
Thanks,
Brett
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:O20NqZ3PFHA.3196@.TK2MSFTNGP12.phx.gbl...
> SQL Server to MSDE and back is a no-brainer. They are the same product.
> Going to other vendors, your best bet is to confine to ANSI SQL. Note that
> some vendors do not support ANSI SQL (also, there are different revisions
> of the ANSI SQL standard). Study up on the candidates and see what level
> of compliance to the ANSI SQL standard they have.Then try to confine your
> code to that. http://www.mimer.com/ has a SQL Validator, might be worth
> checking out.
> But be aware that you will be missing out on a lot of good stuff. Things
> like stored procedures, triggers, a lot of the system functions to mention
> a few things in SQL Server which aren't ANSI SQL compliant (and nor are
> Oracle's and possibly DB2's either).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Brett" <no@.spam.com> wrote in message
> news:%23%23ciH72PFHA.4028@.tk2msftngp13.phx.gbl...
>|||Yep, this is what I would recommend. Keeping the SQL code ANSI compliant wil
l limit you very much
(to the level where you can't use stored procedures against he major DBMS ve
ndors). Encapsulate the
database code and you can exploit the DBMS to the level you feel comfortable
with and which makes
sense to your project.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Brett" <no@.spam.com> wrote in message news:OFK$vl3PFHA.2132@.TK2MSFTNGP14.phx.gbl...darkred">
> MySQL Server is probably the top candidate as it is supported very widely.
MSDE isn't. If in my
> current application I make use of stored procedure calls to SQL Server 200
0, I suppose the best
> way to make the application available for a database switch is to just put
all of the database
> calls into some type of encapsulation. Inside of the encapsulation will b
e either a stored
> procedure call or a query, depending on the database. That sound right?
> Thanks,
> Brett
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n message
> news:O20NqZ3PFHA.3196@.TK2MSFTNGP12.phx.gbl...
>