Showing posts with label msde. Show all posts
Showing posts with label msde. Show all posts

Tuesday, March 27, 2012

Converting data to be inserted into a database

Hi,

I am using web matrix, and I am trying to insert a data into a MSDE database. I have used webmatrix to generate the update code, and it is executed when a button is pressed on the web page. but when the code is executed I get the error:

Syntax error converting the varchar value 'txtAmountSold.text' to a column of data type int.

So I added the following code to try to convert the data, but i am still getting the same error, with txtAmountSold.text replaced with "test"

dim test as integer
test = Convert.ToInt32(txtAmountSold.text)

Here is the whole of the function I am using:

Function AddItemToStock() As Integer

dim test as integer
test = Convert.ToInt32(txtAmountSold.text)

Dim connectionString As String = "server='(local)\Matrix'; trusted_connection=true; database='HawkinsComputers'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "INSERT INTO [stock] ([Catagory], [Type], [Name], [Manufacturer], [Price], [Weight"& _
"], [Description], [image], [OnOffer], [OfferPr"& _
"ice], [OfferDescription], [AmountInStock], [AmountOnOrder], [AmountSold]) VALUES ('CatList.SelectedItem.text', 'txtType.text', 'txtname.text', 'txtmanufacturer.text'"& _
", convert(money,'txtPrice.text'), 'txtWeight.text', 'txtDescription.text', 'txtimage.text', 'txtOnOffer"& _
".text', convert(money,'txtOfferPrice.text'), 'txtOfferDescrip"& _
"tion.text', 'txtAmountInStock.text', 'txtAmountOnOrder.text', 'test')"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try

Return rowsAffected
End Function

Any help in solving this problem would be greatly appreciated, as I am really stuck for where to go next.The probably is that you are trying to send the literal value 'test' as a parameter value.

Please use this approach instead:
Dim queryString As String = "INSERT INTO [stock] ([Catagory], [Type], [Name], [Manufacturer], [Price], [Weight"& _
"], [Description], [image], [OnOffer], [OfferPr"& _
"ice], [OfferDescription], [AmountInStock], [AmountOnOrder],[AmountSold]) VALUES (@.CatList, @.Type,@.name, @.manufacturer, @.Price, @.Weight, @.Description, @.image, @.OnOffer, @.OfferPrice, @.OfferDescription, @.AmountInStock, @.AmountOnOrder, @.test)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.Parameters.Add("@.CatList,SqlDbType.VarChar,99).Value =
CatList.SelectedItem.text
dbCommand.Parameters.Add("@.Type,SqlDbType.VarChar,50).Value =txtType.text
dbCommand.Parameters.Add("@.Name,SqlDbType.VarChar,30).Value =txtmanufacturer.text
' add all parameters in this manner
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Note that for each parameter you will need to use the appropriate SqlDbType. And if it's a character data type you will also need to specify the length.

Here are some links which should help you with using parameters:
Using Parameterized Query in ASP.NET, Part 1
Using Parameterized Query in ASP.NET, Part 2
Using Parameterized Queries in ASP.Net
How To: Protect From SQL Injection in ASP.NET|||Thanks alot for the reply, Those links will help alot aswell.

Thursday, March 22, 2012

Converting a SQL Database to MSDE

Ok, I've got the tables created, the proc's created (and they work) and
everything else is done on the backend. My question is how to do I get
everything I've created in the database using a full version of SQL into an
MSDE database that I can distribute to my userbase so they can play. Someone
said all I need to do is a backup and restore -- but I'm not sure how it
would be done. Can anyone help?Backup and Restore is all you need.
Backup the database to a flat file
Restore onto MSDE using the flat file.
I would use SQL Enterprise Manager...
--
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
"MisterB" <MisterB@.discussions.microsoft.com> wrote in message
news:65AA739F-3DA8-4CEF-813D-E8E4AFD95DAD@.microsoft.com...
> Ok, I've got the tables created, the proc's created (and they work) and
> everything else is done on the backend. My question is how to do I get
> everything I've created in the database using a full version of SQL into
an
> MSDE database that I can distribute to my userbase so they can play.
Someone
> said all I need to do is a backup and restore -- but I'm not sure how it
> would be done. Can anyone help?|||"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:%23V6IM1p7EHA.1408@.TK2MSFTNGP10.phx.gbl...
> Backup and Restore is all you need.
> Backup the database to a flat file
> Restore onto MSDE using the flat file.
> I would use SQL Enterprise Manager...
Note that the datafile will need to be less than 2 gigabytes.
> --
> 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
> "MisterB" <MisterB@.discussions.microsoft.com> wrote in message
> news:65AA739F-3DA8-4CEF-813D-E8E4AFD95DAD@.microsoft.com...
> > Ok, I've got the tables created, the proc's created (and they work) and
> > everything else is done on the backend. My question is how to do I get
> > everything I've created in the database using a full version of SQL into
> an
> > MSDE database that I can distribute to my userbase so they can play.
> Someone
> > said all I need to do is a backup and restore -- but I'm not sure how it
> > would be done. Can anyone help?
>|||How do you reattach the file(s) you backed up to the MSDE?
"Wayne Snyder" wrote:
> Backup and Restore is all you need.
> Backup the database to a flat file
> Restore onto MSDE using the flat file.
> I would use SQL Enterprise Manager...
> --
> 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
> "MisterB" <MisterB@.discussions.microsoft.com> wrote in message
> news:65AA739F-3DA8-4CEF-813D-E8E4AFD95DAD@.microsoft.com...
> > Ok, I've got the tables created, the proc's created (and they work) and
> > everything else is done on the backend. My question is how to do I get
> > everything I've created in the database using a full version of SQL into
> an
> > MSDE database that I can distribute to my userbase so they can play.
> Someone
> > said all I need to do is a backup and restore -- but I'm not sure how it
> > would be done. Can anyone help?
>
>

Converting a SQL Database to MSDE

Ok, I've got the tables created, the proc's created (and they work) and
everything else is done on the backend. My question is how to do I get
everything I've created in the database using a full version of SQL into an
MSDE database that I can distribute to my userbase so they can play. Someon
e
said all I need to do is a backup and restore -- but I'm not sure how it
would be done. Can anyone help?Backup and Restore is all you need.
Backup the database to a flat file
Restore onto MSDE using the flat file.
I would use SQL Enterprise Manager...
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
"MisterB" <MisterB@.discussions.microsoft.com> wrote in message
news:65AA739F-3DA8-4CEF-813D-E8E4AFD95DAD@.microsoft.com...
> Ok, I've got the tables created, the proc's created (and they work) and
> everything else is done on the backend. My question is how to do I get
> everything I've created in the database using a full version of SQL into
an
> MSDE database that I can distribute to my userbase so they can play.
Someone
> said all I need to do is a backup and restore -- but I'm not sure how it
> would be done. Can anyone help?|||"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:%23V6IM1p7EHA.1408@.TK2MSFTNGP10.phx.gbl...
> Backup and Restore is all you need.
> Backup the database to a flat file
> Restore onto MSDE using the flat file.
> I would use SQL Enterprise Manager...
Note that the datafile will need to be less than 2 gigabytes.

> --
> 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
> "MisterB" <MisterB@.discussions.microsoft.com> wrote in message
> news:65AA739F-3DA8-4CEF-813D-E8E4AFD95DAD@.microsoft.com...
> an
> Someone
>|||How do you reattach the file(s) you backed up to the MSDE?
"Wayne Snyder" wrote:

> Backup and Restore is all you need.
> Backup the database to a flat file
> Restore onto MSDE using the flat file.
> I would use SQL Enterprise Manager...
> --
> 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
> "MisterB" <MisterB@.discussions.microsoft.com> wrote in message
> news:65AA739F-3DA8-4CEF-813D-E8E4AFD95DAD@.microsoft.com...
> an
> Someone
>
>

Converting a SQL Database to MSDE

Ok, I've got the tables created, the proc's created (and they work) and
everything else is done on the backend. My question is how to do I get
everything I've created in the database using a full version of SQL into an
MSDE database that I can distribute to my userbase so they can play. Someone
said all I need to do is a backup and restore -- but I'm not sure how it
would be done. Can anyone help?
Backup and Restore is all you need.
Backup the database to a flat file
Restore onto MSDE using the flat file.
I would use SQL Enterprise Manager...
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
"MisterB" <MisterB@.discussions.microsoft.com> wrote in message
news:65AA739F-3DA8-4CEF-813D-E8E4AFD95DAD@.microsoft.com...
> Ok, I've got the tables created, the proc's created (and they work) and
> everything else is done on the backend. My question is how to do I get
> everything I've created in the database using a full version of SQL into
an
> MSDE database that I can distribute to my userbase so they can play.
Someone
> said all I need to do is a backup and restore -- but I'm not sure how it
> would be done. Can anyone help?
|||"Wayne Snyder" <wayne.nospam.snyder@.mariner-usa.com> wrote in message
news:%23V6IM1p7EHA.1408@.TK2MSFTNGP10.phx.gbl...
> Backup and Restore is all you need.
> Backup the database to a flat file
> Restore onto MSDE using the flat file.
> I would use SQL Enterprise Manager...
Note that the datafile will need to be less than 2 gigabytes.

> --
> 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
> "MisterB" <MisterB@.discussions.microsoft.com> wrote in message
> news:65AA739F-3DA8-4CEF-813D-E8E4AFD95DAD@.microsoft.com...
> an
> Someone
>
|||How do you reattach the file(s) you backed up to the MSDE?
"Wayne Snyder" wrote:

> Backup and Restore is all you need.
> Backup the database to a flat file
> Restore onto MSDE using the flat file.
> I would use SQL Enterprise Manager...
> --
> 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
> "MisterB" <MisterB@.discussions.microsoft.com> wrote in message
> news:65AA739F-3DA8-4CEF-813D-E8E4AFD95DAD@.microsoft.com...
> an
> Someone
>
>

Wednesday, March 7, 2012

Convert sql 7 file to msde 2000

is there any way I can convert a sql7 file to msde 2000.
I don't have sql 7 running, I have msde 2000 running
A detached SQL7 mdf file can be attached to SQL 2000 with an automatic
conversion to the newer platform. The same is true with backups.
Jim
"Slim" <Slim@.slim> wrote in message
news:uyGH7VIJEHA.2884@.TK2MSFTNGP12.phx.gbl...
> is there any way I can convert a sql7 file to msde 2000.
> I don't have sql 7 running, I have msde 2000 running
>
|||is this true for MSDE 2000, not sql 2000
"Jim Young" <thorium48@.hotmail.com> wrote in message
news:ezRsqfIJEHA.3704@.TK2MSFTNGP11.phx.gbl...
> A detached SQL7 mdf file can be attached to SQL 2000 with an automatic
> conversion to the newer platform. The same is true with backups.
> Jim
> "Slim" <Slim@.slim> wrote in message
> news:uyGH7VIJEHA.2884@.TK2MSFTNGP12.phx.gbl...
>
|||Yes, its the same for MSDE 2000.
Jim
"Slim" <Slim@.slim> wrote in message
news:eTwYwyIJEHA.232@.TK2MSFTNGP12.phx.gbl...
> is this true for MSDE 2000, not sql 2000
>
> "Jim Young" <thorium48@.hotmail.com> wrote in message
> news:ezRsqfIJEHA.3704@.TK2MSFTNGP11.phx.gbl...
>
|||Hi,
I read this thread and just want to be sure, because I have a similar problem.
I have the SQL 7 Version already running on my system, because I installed it with an application I can't identify yet.
Now I need to install MSDE2000A, because another (new to install) application demands it.
Do I have to uninstall SQL 7 before or will the installation of MSDE2000A upgrade SQL 7. Or will there be both working?
Will the old application run with the new MSDE?
I'd be happy to learn about all this.

Convert SQL 2005 to MSDE

Is there any way to convert a SQL Server 2005 (v9) database to a MSDE (v8)
database?
No, Once you upgrade or create a V9 database you can't convert to/back to a v8.
Adam J Warne, MCDBA
"Joe Pannone" wrote:

> Is there any way to convert a SQL Server 2005 (v9) database to a MSDE (v8)
> database?
|||You have to export all the data and re-import it back into a MSDE database.
Of course any 2005 specific features or datatypes will be an issue.
Andrew J. Kelly SQL MVP
"Joe Pannone" <JoePannone@.discussions.microsoft.com> wrote in message
news:CE10B408-73C3-497E-9309-85EC2D8AFDB1@.microsoft.com...
> Is there any way to convert a SQL Server 2005 (v9) database to a MSDE (v8)
> database?
|||Once you've upgraded the DB to SQL 2005, is it possible to use Express
Edition in place of MSDE?
Alan Brewer [MSFT]
Content Architect, SQL Server Documentation Team
SQL Server Developer Center: http://msdn.microsoft.com/sql
SQL Server TechCenter: http://technet.microsoft.com/sql/
This posting is provided "AS IS" with no warranties, and confers no rights.

Convert SQL 2005 to MSDE

Is there any way to convert a SQL Server 2005 (v9) database to a MSDE (v8)
database?No, Once you upgrade or create a V9 database you can't convert to/back to a v8.
--
Adam J Warne, MCDBA
"Joe Pannone" wrote:
> Is there any way to convert a SQL Server 2005 (v9) database to a MSDE (v8)
> database?|||You have to export all the data and re-import it back into a MSDE database.
Of course any 2005 specific features or datatypes will be an issue.
--
Andrew J. Kelly SQL MVP
"Joe Pannone" <JoePannone@.discussions.microsoft.com> wrote in message
news:CE10B408-73C3-497E-9309-85EC2D8AFDB1@.microsoft.com...
> Is there any way to convert a SQL Server 2005 (v9) database to a MSDE (v8)
> database?|||Once you've upgraded the DB to SQL 2005, is it possible to use Express
Edition in place of MSDE?
--
Alan Brewer [MSFT]
Content Architect, SQL Server Documentation Team
SQL Server Developer Center: http://msdn.microsoft.com/sql
SQL Server TechCenter: http://technet.microsoft.com/sql/
This posting is provided "AS IS" with no warranties, and confers no rights.

Convert SQL 2005 to MSDE

Is there any way to convert a SQL Server 2005 (v9) database to a MSDE (v8)
database?No, Once you upgrade or create a V9 database you can't convert to/back to a
v8.
--
Adam J Warne, MCDBA
"Joe Pannone" wrote:

> Is there any way to convert a SQL Server 2005 (v9) database to a MSDE (v8)
> database?|||You have to export all the data and re-import it back into a MSDE database.
Of course any 2005 specific features or datatypes will be an issue.
Andrew J. Kelly SQL MVP
"Joe Pannone" <JoePannone@.discussions.microsoft.com> wrote in message
news:CE10B408-73C3-497E-9309-85EC2D8AFDB1@.microsoft.com...
> Is there any way to convert a SQL Server 2005 (v9) database to a MSDE (v8)
> database?|||Once you've upgraded the DB to SQL 2005, is it possible to use Express
Edition in place of MSDE?
Alan Brewer [MSFT]
Content Architect, SQL Server Documentation Team
SQL Server Developer Center: http://msdn.microsoft.com/sql
SQL Server TechCenter: http://technet.microsoft.com/sql/
This posting is provided "AS IS" with no warranties, and confers no rights.