Showing posts with label net. Show all posts
Showing posts with label net. Show all posts

Friday, March 30, 2012

How to create sql for retrieving 10 records per time in .NET

I want to create sql for retrieving 10 records per time but need to know the total result matches.
And I have previous and next button for retrieving previous or next 10 records.
ThanksAs a great man once said: Huh?

I'm sure that your posting made sense to you, but I don't even have a clue what you meant. Could you try to repost and fill in a few of the details that I'm missing? I'd like to help you if I could, but at the moment I don't understand enough of what you want to have a chance!

-PatP|||Hi,

as Pat said, this isn't very clear and you really should repost. I just want to comment on what you may need to consider mentioning.

Almost all databases are used by multiple users at the same time. Selecting the 10 first records in a particular order makes perfect sense, as does selecting record 11 to 20 of that same recordset. But selecting 10 and then (at a later time) selecting "the ten next" doesn't have any clear meaning since the data may well have changed in the meantime. So perhaps it's a good idea to clarify how you want your system to deal with the different change scenarios: records may have been added, removed or updated, or any mix of the three between the two queries.

One way to "page in the database":
Initialize:
- establish a single orderby column for your query (if you have several columns, combine them into one column yielding equivalent sort order)
- select the top 10 records
- persist the value of the orderby column for the last record. In ASP.NET, use ViewState for this.

Each round trip:
- use the value of the last record in the previous result set to select the next ten:
SELECT TOP 10 ... WHERE ... AND ordCol > @.lastValue ORDER BY ordCol
- persist the last value again

Of course, if you require to page the other way (previous page) you must also persist the value of the first record. Furthermore, since there's no BOTTOM keyword to mirror TOP, you must use reverse sort order (otherwise, if you did SELECT TOP 10 ... WHERE ordCol < @.firstVal, the first page would be returned even if you tried to get the previous one from, say, page 5). Since you still want to display in-order, fix this by selecting into a temp table and then select in-order from that one:

SELECT TOP 10 INTO #page ... WHERE ... AND ordCol < @.firstVal ORDER BY ordCol DESC
SELECT * FROM #page ORDER BY ordCol

I hope this helps!

Dag|||Or you could just set-up paging in a datagrid...|||Huh?

Just a guess...

You want to do paging

http://weblogs.sqlteam.com/jeffs/ar...03/22/1085.aspx

Make sure to say hi to Jeff for me
__________________|||I meant that you could use a .NET DataGrid control that allows you to view a recordset one page at a time. You can define how many records you want displayed on each page. Of course this deals with paging at the Application level - don't know if that's what he wants but just thought I'd mention it.

I don't have a clue about paging at the SQL Server level...:-)|||Sorry for unclear question. Yes, what i want to do is paging.
Brett: The URL http://weblogs.sqlteam.com/jeffs/ar...03/22/1085.aspx is unavailable
mmcdonald: Thanks for your suggestion but the user don't want the result be shown in datagrid :(

How to create reports dinamically?

Hello. Can I make a report for example with all the columns and make a
program in asp.net in which the user can select the columns he wants to see?
Thanks.Yes of course, unless RDL is a open Language you can stick your parts
together as the User wants. But I would keep in mind that there are already
thrid party tools to do that, therefore looking at these will eventually
save you time and money fordeveloping that on your own.
--
HTH, Jens Suessmeyer.
--
http://www.sqlserver2005.de
--
"Luis Esteban Valencia" <levalencia@.avansoft.com> schrieb im Newsbeitrag
news:OZDxaTydFHA.1684@.TK2MSFTNGP09.phx.gbl...
> Hello. Can I make a report for example with all the columns and make a
> program in asp.net in which the user can select the columns he wants to
> see?
> Thanks.
>|||Your page doesnt work
"Jens Süßmeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> escribió
en el mensaje news:elyDct0dFHA.220@.TK2MSFTNGP12.phx.gbl...
> Yes of course, unless RDL is a open Language you can stick your parts
> together as the User wants. But I would keep in mind that there are
already
> thrid party tools to do that, therefore looking at these will eventually
> save you time and money fordeveloping that on your own.
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "Luis Esteban Valencia" <levalencia@.avansoft.com> schrieb im Newsbeitrag
> news:OZDxaTydFHA.1684@.TK2MSFTNGP09.phx.gbl...
> > Hello. Can I make a report for example with all the columns and make a
> > program in asp.net in which the user can select the columns he wants to
> > see?
> >
> > Thanks.
> >
> >
>sql

Wednesday, March 28, 2012

how to create primary keys on compound fields?

Hi everyone,
I am now getting seriously into VB.Net development as a front end to SQL
server. After working about 20 yrs with DBF's and various xBase
programs (dBase, FoxPro, Clipper, etc), I am now convinced VB/SQL is the
way to go
I have a few questions:
I've successfully imported DBF files into SQL server (MSDE) but I can't
seem to create a data adapter (in VB) unless I have a primary key
defined. Do tables require primary keys be defined prior to dragging
them onto a forms and working with datagrids?
How can I create a primary key on a compound field? For a simple key
(one field), I know to open the server explorer, go into design mode,
then right click the field and set primary key. This works well ... but
... what about a 'details' table where the only unique key is a
combination of many fields (might be mixed type too), ex: customer
(char) + item (numeric) + color (char). How does one do that?
Thanks in advance
Richard Fagen
--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
In the table design high-light each column name you want to make PK and
click the PK icon (a gold key symbol) in the toolbar. You high-light
each column by holding down the control key and clicking the square to
the left of the column name.
You could also use a DDL statement to create a PK:
ALTER TABLE table_name ADD CONSTRAINT PK_table_name PRIMARY KEY (col1,
col2, col3)
The coln are the column names that will comprise the PK.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQbTkE4echKqOuFEgEQI7uACg3KvX6c2lJy7M9loRVsXQbs 732YwAnRKD
6CSubCv+n/TA2EUvULyWke2E
=qfj3
--END PGP SIGNATURE--
Richard Fagen wrote:
> Hi everyone,
> I am now getting seriously into VB.Net development as a front end to SQL
> server. After working about 20 yrs with DBF's and various xBase
> programs (dBase, FoxPro, Clipper, etc), I am now convinced VB/SQL is the
> way to go
> I have a few questions:
> I've successfully imported DBF files into SQL server (MSDE) but I can't
> seem to create a data adapter (in VB) unless I have a primary key
> defined. Do tables require primary keys be defined prior to dragging
> them onto a forms and working with datagrids?
> How can I create a primary key on a compound field? For a simple key
> (one field), I know to open the server explorer, go into design mode,
> then right click the field and set primary key. This works well ... but
> ... what about a 'details' table where the only unique key is a
> combination of many fields (might be mixed type too), ex: customer
> (char) + item (numeric) + color (char). How does one do that?
|||Hi,
Thanks for your reply. I never noticed the gold key icon, I was using
the right click popup menu While it appears to work, when I try to
save the changes to the file, I get the same error message...
'PRODUCT' table
- Unable to modify table.
ADO error: Cannot insert the value NULL into column 'PREF', table
'sterilite.dbo.Tmp_PRODUCT'; column does not allow nulls. INSERT fails.
The statement has been terminated.
I imported the DBF files via SQL servers' tools. I thought everything
was ok as in the server explorer, I see the database with all the tables
(foxpro files) inside it. I can also browse the data. I did notice the
'allow nulls' column was checked. I tried unchecking it but I get the
same error.
The foxpro file originally had a 'pref' C4 (for the 'prefix' code, a
character field, width 4) and I don't know what to try next.
In DBF syntax, the unique fields are:
pref, C4 (prefix of item)
item, C4 (item code)
color, C2 (color code)
cu_code, C4 (customer code)
All these fields get translated into 'varchar' type with the appropriate
widths and the allow nulls checked.
Any ideas?
Thanks
Richard
MGFoster wrote:
> --BEGIN PGP SIGNED MESSAGE--
> Hash: SHA1
> In the table design high-light each column name you want to make PK and
> click the PK icon (a gold key symbol) in the toolbar. You high-light
> each column by holding down the control key and clicking the square to
> the left of the column name.
> You could also use a DDL statement to create a PK:
> ALTER TABLE table_name ADD CONSTRAINT PK_table_name PRIMARY KEY (col1,
> col2, col3)
> The coln are the column names that will comprise the PK.
>
|||--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
In RDBMS (SQL dbs) each row's Primary Key columns require data, i.e.,
they cannot be NULL. The error you're getting means that the PREF
column has NULL values in some, or all, of the imported rows. This
means the columns you've selected for PKs are not a good choice, or you
need to fix the data so there is a value in the PREF column for each
row.
It would seem that the columns item, color, cu_code, would be good
candidates for PK if they always have values per row, and, the 3 column
values, taken together, represent a unique value in the table.
Is the PREF column useful as part of a unique identifier (PK)? If so,
then it should have data.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQbUGaoechKqOuFEgEQK43gCg4pund4SFw+VpPdFrYlcLoG iwV5wAnjzV
aFvBbWaz/Xm1Y1XKxbpzG7wQ
=rrhn
--END PGP SIGNATURE--
Richard Fagen wrote:[vbcol=seagreen]
> Hi,
> Thanks for your reply. I never noticed the gold key icon, I was using
> the right click popup menu While it appears to work, when I try to
> save the changes to the file, I get the same error message...
> 'PRODUCT' table
> - Unable to modify table.
> ADO error: Cannot insert the value NULL into column 'PREF', table
> 'sterilite.dbo.Tmp_PRODUCT'; column does not allow nulls. INSERT fails.
> The statement has been terminated.
> I imported the DBF files via SQL servers' tools. I thought everything
> was ok as in the server explorer, I see the database with all the tables
> (foxpro files) inside it. I can also browse the data. I did notice the
> 'allow nulls' column was checked. I tried unchecking it but I get the
> same error.
> The foxpro file originally had a 'pref' C4 (for the 'prefix' code, a
> character field, width 4) and I don't know what to try next.
> In DBF syntax, the unique fields are:
> pref, C4 (prefix of item)
> item, C4 (item code)
> color, C2 (color code)
> cu_code, C4 (customer code)
> All these fields get translated into 'varchar' type with the appropriate
> widths and the allow nulls checked.
> Any ideas?
> Thanks
> Richard
>
>
> MGFoster wrote:
|||That must be it! Yes, some values of Pref are null. Strange, in the
DBF format it was a blank character field, but when it was imported in
SQL, it became <null>
While I might be able to get around this by excluding 'pref' from the
key, I'll have that problem for other fields as some items don't have
colours and they also appear with <null> in SQL format.
They would still be unique as if an item only comes in one colour, the
DBF file had a blank. Can I globally change all <null> to " " (blank
characters) to fix this.
Thanks for figuring out what the problem was!
Richard
MGFoster wrote:
> --BEGIN PGP SIGNED MESSAGE--
> Hash: SHA1
> In RDBMS (SQL dbs) each row's Primary Key columns require data, i.e.,
> they cannot be NULL. The error you're getting means that the PREF
> column has NULL values in some, or all, of the imported rows. This
> means the columns you've selected for PKs are not a good choice, or you
> need to fix the data so there is a value in the PREF column for each
> row.
> It would seem that the columns item, color, cu_code, would be good
> candidates for PK if they always have values per row, and, the 3 column
> values, taken together, represent a unique value in the table.
> Is the PREF column useful as part of a unique identifier (PK)? If so,
> then it should have data.
>
|||--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
You can change all values of one column, but that will not fix your
problem. For the PK, what you need to do is pick one, or more, columns
whose values uniquely identify the row. Each of these columns MUST have
data for every row. There cannot be rows where these columns have equal
values. E.g. (the 3 columns that make up the PK):
item colour cu_code
1 2 9988
1 3 9988
1 2 9988 <- PK constraint violation 'cuz equals 1st
row.
It would seem that this table would have a Date column. You could
include the date column in the PK & have something like this:
item colour cu_code order_date
1 2 9988 20040115
1 3 9988 20040115
1 2 9988 20040120 <- now OK 'cuz order_date makes
row different from 1st row.
If the columns you pick as the PK have rows w/o data then you will have
to do, what is known as, "Data Clean Up." Which should be done by your
client since they are the ones who created this mess to begin with.
I suggest you get a good book on database design to help you figure out
construction of primary keys, foreign keys, indexes, etc. I've
recommended _Database Design for Mere Mortals_ by Hernandez.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQbVhPIechKqOuFEgEQLJGQCgjejMWSmlyiNAELht8FvPb2 BluRsAoORW
6ofwJ8Gby1KYNurkiHCb1NM+
=Ode3
--END PGP SIGNATURE--
Richard Fagen wrote:[vbcol=seagreen]
> That must be it! Yes, some values of Pref are null. Strange, in the
> DBF format it was a blank character field, but when it was imported in
> SQL, it became <null>
> While I might be able to get around this by excluding 'pref' from the
> key, I'll have that problem for other fields as some items don't have
> colours and they also appear with <null> in SQL format.
> They would still be unique as if an item only comes in one colour, the
> DBF file had a blank. Can I globally change all <null> to " " (blank
> characters) to fix this.
> Thanks for figuring out what the problem was!
> Richard
> MGFoster wrote:
|||Hi,
Thanks for your prompt reply. I will definitely check out that book. I
have collected quite a library over the years and I'm always reading
many tech books at once
I'm aware of the requirement of a unique value for each record, it is
just some records, when imported from DBF (Foxpro/DOS) have null values.
In DBF format, spaces were stored. I'm not sure why importing the
files into SQL tables cause them to change to <nulls> Maybe I didn't
check off some option during the import process?
Ex:
ItemColourCu_code... more fields here
11Walmart
12Walmart
13Walmart
2<null>Walmart <- problem here, it was blank in the DBF,
some items have a single record that is blank,
it will still be unique, just one " " value
for that cu_code/item combination
31Walmart
32Walmart
Your idea to incorporate another field is a great idea. You are right,
I will have the same problem elsewhere unless I add an orderdate (or
invoice #) to the key. I don't know how to get rid of the <nulls> for
the blank DBFs that were imported into SQL/
I was thinking of replacing the blanks in the DBF with a dummy symbol
(say *) before importing into SQL format. Then I'd use OSQL to replace
the dummy with " ". Is there an easier way?
Thanks again.
Richard
MGFoster wrote:
> --BEGIN PGP SIGNED MESSAGE--
> Hash: SHA1
> You can change all values of one column, but that will not fix your
> problem. For the PK, what you need to do is pick one, or more, columns
> whose values uniquely identify the row. Each of these columns MUST have
> data for every row. There cannot be rows where these columns have equal
> values. E.g. (the 3 columns that make up the PK):
> item colour cu_code
> 1 2 9988
> 1 3 9988
> 1 2 9988 <- PK constraint violation 'cuz equals 1st
> row.
> It would seem that this table would have a Date column. You could
> include the date column in the PK & have something like this:
> item colour cu_code order_date
> 1 2 9988 20040115
> 1 3 9988 20040115
> 1 2 9988 20040120 <- now OK 'cuz order_date makes
> row different from 1st row.
> If the columns you pick as the PK have rows w/o data then you will have
> to do, what is known as, "Data Clean Up." Which should be done by your
> client since they are the ones who created this mess to begin with.
> I suggest you get a good book on database design to help you figure out
> construction of primary keys, foreign keys, indexes, etc. I've
> recommended _Database Design for Mere Mortals_ by Hernandez.
>
|||--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
It would seem that replacing the "*" with a space would be redundant,
since you're just inserting a "holding character" until you get valid
data, and that holding character can be an asterisk as easily as a
space.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQbYol4echKqOuFEgEQIcRACg0oDX4sr3G7MWGLBjVSDoTU 2tUjgAn3UM
Cg//imB7G3nJKMWBWBZRffvf
=Is8Z
--END PGP SIGNATURE--
Richard Fagen wrote:[vbcol=seagreen]
> Hi,
> Thanks for your prompt reply. I will definitely check out that book. I
> have collected quite a library over the years and I'm always reading
> many tech books at once
> I'm aware of the requirement of a unique value for each record, it is
> just some records, when imported from DBF (Foxpro/DOS) have null values.
> In DBF format, spaces were stored. I'm not sure why importing the
> files into SQL tables cause them to change to <nulls> Maybe I didn't
> check off some option during the import process?
> Ex:
> Item Colour Cu_code ... more fields here
> 1 1 Walmart
> 1 2 Walmart
> 1 3 Walmart
> 2 <null> Walmart <- problem here, it was blank in the DBF,
> some items have a single record that is blank,
> it will still be unique, just one " " value
> for that cu_code/item combination
> 3 1 Walmart
> 3 2 Walmart
> Your idea to incorporate another field is a great idea. You are right,
> I will have the same problem elsewhere unless I add an orderdate (or
> invoice #) to the key. I don't know how to get rid of the <nulls> for
> the blank DBFs that were imported into SQL/
> I was thinking of replacing the blanks in the DBF with a dummy symbol
> (say *) before importing into SQL format. Then I'd use OSQL to replace
> the dummy with " ". Is there an easier way?
> Thanks again.
> Richard
> MGFoster wrote:
|||Can't a blank value (" ") be valid if it is part of a unique compound
key?
There must be some OSQL statement that I can use.
In anycase, is there a simple way to change all the <null> values to
blank spaces? I know I can use the server explorer to browse and edit
values, but certain tables have 1000's of <null> values in certain columns.
Thanks
Richard
MGFoster wrote:

> --BEGIN PGP SIGNED MESSAGE--
> Hash: SHA1
> It would seem that replacing the "*" with a space would be redundant,
> since you're just inserting a "holding character" until you get valid
> data, and that holding character can be an asterisk as easily as a
> space.
>
|||--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
You can change NULLs to another character(s) using an update like this:
UPDATE table_name
SET column_name = '*'
WHERE column_name IS NULL
I'd use an actual character, 'cuz some query results thru other
applications (MS Access) will seem to be a space (blank), but, in fact,
will be a NULL.
What I was trying to get at is this may not enable a PK to be
established on the columns you want to make a PK, because, putting a
character in the column may not make a unique PK. E.g.:
BEFORE:
item colour cu_code
NULL 1 9998
2 NULL 9998
NULL 1 9998
AFTER:
item colour cu_code
* 1 9998
2 * 9998
* 1 9998 <- violates PK constraint 'cuz equals row 1.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQbY6KoechKqOuFEgEQKgvACfeROn2fzUzR88HCv9HxPmvY Pl3YcAoMM6
lDykLHrwNeYAAUzf6vFHbpmb
=r+De
--END PGP SIGNATURE--
Richard Fagen wrote:[vbcol=seagreen]
> Can't a blank value (" ") be valid if it is part of a unique compound
> key?
> There must be some OSQL statement that I can use.
> In anycase, is there a simple way to change all the <null> values to
> blank spaces? I know I can use the server explorer to browse and edit
> values, but certain tables have 1000's of <null> values in certain columns.
> Thanks
> Richard
>
> MGFoster wrote:
sql

how to create parameterised views?

I am using SqlServer2005 and asp.net 2005. I have a large database for which I have to provide reports for it. I need a report that user will specify a date, and the report will be run, from this month & year and I will calculate the first day of the month and the last day of the month and these will serve as the input parameters for a long SELECT query.

For my previous reports i've used views . But for this functionality i need a parameterized view, which i cant create.

Please help me how to create a parameterized view...

Thanks in Advance...

Use a stored procedure.

|||

Given a date and if you need to find the first day of the month/last day of the month here's how you can do it.

DECLARE @.DdatetimeSET @.D =getdate()SELECT ,DATEADD(dd, -DATEPART(dd,GETDATE()) + 1,GETDATE())'First day of the month' ,DATEADD(d, -DAY(DATEADD(m,1,@.Date)),DATEADD(m,1,@.Date))AS'Last day of the month'

You can use the same in a view as follows:

SELECTFROM dbo.vwSomeViewWHERE DatecolumnBETWEEN @.begDateAND @.EndDate
|||

You can't create a parameterized view. You can create a view and then filter it. Or you can create a table valued function, which is pretty close to a parameterized view.

how to create my Validate Login SP IN sql 2000 ?

hi,all:

I'm new to Sql 2000,now I have a login asp.net page and I used the sql 2000 database.

my login page included a user id and password need user inputed. if the user input the correct userid

and password ,IE will transfer to main page,or there will show eorror message in login page.

my SP like this:

CREATE PROCEDURE dbo.Usp_Accounts_ValidateLogin
@.userid char(4) ,
@.EncPassword binary
AS
if (select count(*) from hhmxUserData whereUserid=@.userid andUserPWD=@.EncPassword) >0

return 1

else

return 0
GO
my asp.net code like this:

dim result As Integer

dim rowsAffected as integer

myConnection.Open()
Dim command As SqlCommand = BuildIntCommand(storedProcName, parameters)
rowsAffected = command.ExecuteNonQuery
result = CInt(command.Parameters("ReturnValue").Value)
myConnection.Close()

Return result

I test it in sql 2000,it's ok.but when I performed it and retrieve the "returnValue", it still return 0 .

so how can I create my correct SP ?

thanks so much.

Change your datatype of userid from char(4) to varchar(4). When you use CHAR, if your user enter the userid which is less than 4 characters in length spaces will be added at the end and your search query may not look like what is should be.

|||

Yes,my UserID is fixed 4 characters length (like: 1012,1008),I think it's not problem,the point is I'm always get the wrong returnValue in my asp.net code when I performed my SP.

So maybe my SP has problem ?

|||

I would recommend you use OUTPUT parameters. check out Books On Line for more info.

check the 2nd part inthis articleto retrieve the output from OUTPUT variable.

Monday, March 19, 2012

How to create a SAPConnection in .Net Code with .NET Data Provider

In the SQL Server Technical Article Microsoft .NET Data Provider for mySAP? Business Suite

is a Code example of how to invoke a BAPI in .Net Code. First line shows how to create a Connection to SAP, but there is no information in which lib the SAPConnection type is stored:

SAPConnection con = new SAPConnection("ASHOST=<SAPserver>; CLIENT=<client>;SYSNR=<sysnr>;USER=<user>;PASSWD=<password>;LANG=<logon

language>");
con.Open();

Does somebody can help me?Assembly Microsoft.Adapter.SAP.SAPProvider|||Correct! That really helped me out! Thanks.

Wednesday, March 7, 2012

How to create a assembly

Hi,

I have one ClassLibrary three member functions.I have the dll for this...Can some one please tell me how to create a Assembly in .NET.

I need to create a simple private assembly with the dll that i have.

Thanks

Did you check out the CLR programmability samples? See below link:

http://msdn2.microsoft.com/en-us/library/ms160894.aspx

You can use CREATE ASSEMBLY DDL to create assembly in SQL Server or use the Visual Studio GUI. See Books Online for more details.

|||

I am guessing that this is for SQL Server.

create assembly AssemblyName
from '<path>\AssemblyName.dll'
go

--Then you can declare the objects within using syntax like:
CREATE FUNCTION [dbo].[DeployName](@.ParameterName [nvarchar](4000))
RETURNS [nvarchar](4000) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [AssemblyName].[RootNamespace.ClassName].[FunctionName]
GO

Or do you mean what you have to do to build the code to make the assembly ready for SQL Server?

How to create .dbf file from within asp.net pages?

Hi,I'd like to create a single .dbf file from within my asp.net application and populate it with some data in SQL Server database,How can I do?Any help will be greatly appreciated!Thanks in advance!You could try looking at the xBase Engine for C# and ASP.NET, written by Ricardo Federico Villafañes:http://www.c-sharpcorner.com/Code/2002/Feb/xBaseEngineRFV.asp

Terri

How to creat a database via SQL Querry Analyzer to a Web Server

I am new to ASP.NET and met a problem about access a database on a Web Server (www.myserver.com). My meaning here that I created a .sql from my localhost to test, but when to upload to my web server on the internet, an error occured: "System.Data.SqlClient.SqlException: SQL Server does not exist or access denied".
Anyone here can help me to solve my problem. Waiting for your reply soon. Thanksyour SQL Connection on your local host and your Server aren't the same. your should check your connectionstring, eypecially the servername.|||First of all thank to MISIU...
Your idea i had to try first! Just here, I change my line of code from <Add key> to a connection string to myserver for instance hereby. But nothing looked good and still got the above problem. Could you pls show me the detail of creat a database and publish it to my Web Server. And i am waiting for anyone give me the BEST. God bless all of you!

Friday, February 24, 2012

How to count a very large volume of request

Hello,
What is the best way to accomplish the following.
1) An ASP.NET program (consiting of one file somepage.aspx) receives about
25,000,000 requests pay day.
2) The requests come from a limited set of IP addresses.
3) How to count the total number of request from each IP address per day.
SQL Server 2000 is used on the backend.
Currently we used the following architecture:
* Each request to somepage.aspx generates an INSERT into a LogTable1
* There is a clustered index on the LogTable1 on the dateStamp field which
is of the type smalldatetime
* The dateStamp field has a default that sets it to the getdate()
* At the end of each day at 12:01AM there is a simple query that runs and
does a group by to count the number of requests from each IP in the given
date range (past 24 hours). This query works great and takes only 2 minutes
to run.
Is there a better way to accomplish this without having to do INSERTS into
the LogTable1 for each request?
It would not work to have the ASP.NET program execute an UPDATE each time to
increment the total number of request, since this would cause LOTSSS of
locking in the database layer.
Thanks in advance.
ArsenYou could store the data in your Application Cache, and update it
periodically to the database.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
news:emdbHKo6DHA.2412@.TK2MSFTNGP09.phx.gbl...
quote:

> Hello,
> What is the best way to accomplish the following.
> 1) An ASP.NET program (consiting of one file somepage.aspx) receives about
> 25,000,000 requests pay day.
> 2) The requests come from a limited set of IP addresses.
> 3) How to count the total number of request from each IP address per day.
> SQL Server 2000 is used on the backend.
> Currently we used the following architecture:
> * Each request to somepage.aspx generates an INSERT into a LogTable1
> * There is a clustered index on the LogTable1 on the dateStamp field which
> is of the type smalldatetime
> * The dateStamp field has a default that sets it to the getdate()
> * At the end of each day at 12:01AM there is a simple query that runs and
> does a group by to count the number of requests from each IP in the given
> date range (past 24 hours). This query works great and takes only 2

minutes
quote:

> to run.
> Is there a better way to accomplish this without having to do INSERTS into
> the LogTable1 for each request?
> It would not work to have the ASP.NET program execute an UPDATE each time

to
quote:

> increment the total number of request, since this would cause LOTSSS of
> locking in the database layer.
> Thanks in advance.
> Arsen
>
|||Hi,
What about using the IIS log file?
you could set it in the way you need it, basically the client IP and maybe
the time, if you configure it to update daily all you have to do at 12:01
is run a process that read the file generated and do what you need.
Cheers,
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
news:emdbHKo6DHA.2412@.TK2MSFTNGP09.phx.gbl...
quote:

> Hello,
> What is the best way to accomplish the following.
> 1) An ASP.NET program (consiting of one file somepage.aspx) receives about
> 25,000,000 requests pay day.
> 2) The requests come from a limited set of IP addresses.
> 3) How to count the total number of request from each IP address per day.
> SQL Server 2000 is used on the backend.
> Currently we used the following architecture:
> * Each request to somepage.aspx generates an INSERT into a LogTable1
> * There is a clustered index on the LogTable1 on the dateStamp field which
> is of the type smalldatetime
> * The dateStamp field has a default that sets it to the getdate()
> * At the end of each day at 12:01AM there is a simple query that runs and
> does a group by to count the number of requests from each IP in the given
> date range (past 24 hours). This query works great and takes only 2

minutes
quote:

> to run.
> Is there a better way to accomplish this without having to do INSERTS into
> the LogTable1 for each request?
> It would not work to have the ASP.NET program execute an UPDATE each time

to
quote:

> increment the total number of request, since this would cause LOTSSS of
> locking in the database layer.
> Thanks in advance.
> Arsen
>
|||Hi Kevin,
Do you suggest storing the TOTALs in the Cache?
Or storing the actual requests: date and ip
Would there be a locking problem?
How to do the "periodic updates" to the database from the Cache?
Thanks,
Arsen
"Kevin Spencer" <kevin@.takempis.com> wrote in message
news:ezSYvso6DHA.1936@.TK2MSFTNGP12.phx.gbl...
quote:

> You could store the data in your Application Cache, and update it
> periodically to the database.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
> "Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
> news:emdbHKo6DHA.2412@.TK2MSFTNGP09.phx.gbl...
about[QUOTE]
day.[QUOTE]
which[QUOTE]
and[QUOTE]
given[QUOTE]
> minutes
into[QUOTE]
time[QUOTE]
> to
>
|||Hi Arsen,
You could put a DataTable in the Application Cache, and add records to it
with each Request. As for periodic updating, you could put a routine in the
Session_OnStart Sub that checks an Application DateTime variable, and at
certain intervals, inserts all the records from the DataTable into the
database and clears out the DataTable.
To be safe, you would want to add code to your Application_OnEnd sub to
update the database if the Application stops or times out; however, with 25M
requests per day, that might not be necessary.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
news:#daQL6o6DHA.2908@.tk2msftngp13.phx.gbl...
quote:

> Hi Kevin,
> Do you suggest storing the TOTALs in the Cache?
> Or storing the actual requests: date and ip
> Would there be a locking problem?
> How to do the "periodic updates" to the database from the Cache?
> Thanks,
> Arsen
> "Kevin Spencer" <kevin@.takempis.com> wrote in message
> news:ezSYvso6DHA.1936@.TK2MSFTNGP12.phx.gbl...
> about
> day.
> which
> and
> given
> into
> time
of[QUOTE]
>
|||what i have done is cache the last 15 minutes. the cache has the ipaddress,
the start of the 15 min interval, pagename, and number of hits during the
interval. as most users cluster their hits, this cuts down the number of
inserts.
i flush the cache every 15 minutes of when too large.
you can then get daily or hourly stats from the db with simple queries.
-- bruce (sqlwork.com)
"Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
news:emdbHKo6DHA.2412@.TK2MSFTNGP09.phx.gbl...
quote:

> Hello,
> What is the best way to accomplish the following.
> 1) An ASP.NET program (consiting of one file somepage.aspx) receives about
> 25,000,000 requests pay day.
> 2) The requests come from a limited set of IP addresses.
> 3) How to count the total number of request from each IP address per day.
> SQL Server 2000 is used on the backend.
> Currently we used the following architecture:
> * Each request to somepage.aspx generates an INSERT into a LogTable1
> * There is a clustered index on the LogTable1 on the dateStamp field which
> is of the type smalldatetime
> * The dateStamp field has a default that sets it to the getdate()
> * At the end of each day at 12:01AM there is a simple query that runs and
> does a group by to count the number of requests from each IP in the given
> date range (past 24 hours). This query works great and takes only 2

minutes
quote:

> to run.
> Is there a better way to accomplish this without having to do INSERTS into
> the LogTable1 for each request?
> It would not work to have the ASP.NET program execute an UPDATE each time

to
quote:

> increment the total number of request, since this would cause LOTSSS of
> locking in the database layer.
> Thanks in advance.
> Arsen
>

How to count a very large volume of request

Hello,
What is the best way to accomplish the following.
1) An ASP.NET program (consiting of one file somepage.aspx) receives about
25,000,000 requests pay day.
2) The requests come from a limited set of IP addresses.
3) How to count the total number of request from each IP address per day.
SQL Server 2000 is used on the backend.
Currently we used the following architecture:
* Each request to somepage.aspx generates an INSERT into a LogTable1
* There is a clustered index on the LogTable1 on the dateStamp field which
is of the type smalldatetime
* The dateStamp field has a default that sets it to the getdate()
* At the end of each day at 12:01AM there is a simple query that runs and
does a group by to count the number of requests from each IP in the given
date range (past 24 hours). This query works great and takes only 2 minutes
to run.
Is there a better way to accomplish this without having to do INSERTS into
the LogTable1 for each request?
It would not work to have the ASP.NET program execute an UPDATE each time to
increment the total number of request, since this would cause LOTSSS of
locking in the database layer.
Thanks in advance.
ArsenYou could store the data in your Application Cache, and update it
periodically to the database.
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
news:emdbHKo6DHA.2412@.TK2MSFTNGP09.phx.gbl...
> Hello,
> What is the best way to accomplish the following.
> 1) An ASP.NET program (consiting of one file somepage.aspx) receives about
> 25,000,000 requests pay day.
> 2) The requests come from a limited set of IP addresses.
> 3) How to count the total number of request from each IP address per day.
> SQL Server 2000 is used on the backend.
> Currently we used the following architecture:
> * Each request to somepage.aspx generates an INSERT into a LogTable1
> * There is a clustered index on the LogTable1 on the dateStamp field which
> is of the type smalldatetime
> * The dateStamp field has a default that sets it to the getdate()
> * At the end of each day at 12:01AM there is a simple query that runs and
> does a group by to count the number of requests from each IP in the given
> date range (past 24 hours). This query works great and takes only 2
minutes
> to run.
> Is there a better way to accomplish this without having to do INSERTS into
> the LogTable1 for each request?
> It would not work to have the ASP.NET program execute an UPDATE each time
to
> increment the total number of request, since this would cause LOTSSS of
> locking in the database layer.
> Thanks in advance.
> Arsen
>|||Hi,
What about using the IIS log file?
you could set it in the way you need it, basically the client IP and maybe
the time, if you configure it to update daily all you have to do at 12:01
is run a process that read the file generated and do what you need.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
news:emdbHKo6DHA.2412@.TK2MSFTNGP09.phx.gbl...
> Hello,
> What is the best way to accomplish the following.
> 1) An ASP.NET program (consiting of one file somepage.aspx) receives about
> 25,000,000 requests pay day.
> 2) The requests come from a limited set of IP addresses.
> 3) How to count the total number of request from each IP address per day.
> SQL Server 2000 is used on the backend.
> Currently we used the following architecture:
> * Each request to somepage.aspx generates an INSERT into a LogTable1
> * There is a clustered index on the LogTable1 on the dateStamp field which
> is of the type smalldatetime
> * The dateStamp field has a default that sets it to the getdate()
> * At the end of each day at 12:01AM there is a simple query that runs and
> does a group by to count the number of requests from each IP in the given
> date range (past 24 hours). This query works great and takes only 2
minutes
> to run.
> Is there a better way to accomplish this without having to do INSERTS into
> the LogTable1 for each request?
> It would not work to have the ASP.NET program execute an UPDATE each time
to
> increment the total number of request, since this would cause LOTSSS of
> locking in the database layer.
> Thanks in advance.
> Arsen
>|||Hi Kevin,
Do you suggest storing the TOTALs in the Cache?
Or storing the actual requests: date and ip
Would there be a locking problem?
How to do the "periodic updates" to the database from the Cache?
Thanks,
Arsen
"Kevin Spencer" <kevin@.takempis.com> wrote in message
news:ezSYvso6DHA.1936@.TK2MSFTNGP12.phx.gbl...
> You could store the data in your Application Cache, and update it
> periodically to the database.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
> "Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
> news:emdbHKo6DHA.2412@.TK2MSFTNGP09.phx.gbl...
> > Hello,
> >
> > What is the best way to accomplish the following.
> >
> > 1) An ASP.NET program (consiting of one file somepage.aspx) receives
about
> > 25,000,000 requests pay day.
> >
> > 2) The requests come from a limited set of IP addresses.
> >
> > 3) How to count the total number of request from each IP address per
day.
> >
> > SQL Server 2000 is used on the backend.
> >
> > Currently we used the following architecture:
> >
> > * Each request to somepage.aspx generates an INSERT into a LogTable1
> > * There is a clustered index on the LogTable1 on the dateStamp field
which
> > is of the type smalldatetime
> > * The dateStamp field has a default that sets it to the getdate()
> > * At the end of each day at 12:01AM there is a simple query that runs
and
> > does a group by to count the number of requests from each IP in the
given
> > date range (past 24 hours). This query works great and takes only 2
> minutes
> > to run.
> >
> > Is there a better way to accomplish this without having to do INSERTS
into
> > the LogTable1 for each request?
> >
> > It would not work to have the ASP.NET program execute an UPDATE each
time
> to
> > increment the total number of request, since this would cause LOTSSS of
> > locking in the database layer.
> >
> > Thanks in advance.
> >
> > Arsen
> >
> >
>|||Hi Arsen,
You could put a DataTable in the Application Cache, and add records to it
with each Request. As for periodic updating, you could put a routine in the
Session_OnStart Sub that checks an Application DateTime variable, and at
certain intervals, inserts all the records from the DataTable into the
database and clears out the DataTable.
To be safe, you would want to add code to your Application_OnEnd sub to
update the database if the Application stops or times out; however, with 25M
requests per day, that might not be necessary.
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
news:#daQL6o6DHA.2908@.tk2msftngp13.phx.gbl...
> Hi Kevin,
> Do you suggest storing the TOTALs in the Cache?
> Or storing the actual requests: date and ip
> Would there be a locking problem?
> How to do the "periodic updates" to the database from the Cache?
> Thanks,
> Arsen
> "Kevin Spencer" <kevin@.takempis.com> wrote in message
> news:ezSYvso6DHA.1936@.TK2MSFTNGP12.phx.gbl...
> > You could store the data in your Application Cache, and update it
> > periodically to the database.
> >
> > --
> > HTH,
> > Kevin Spencer
> > .Net Developer
> > Microsoft MVP
> > Big things are made up
> > of lots of little things.
> >
> > "Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
> > news:emdbHKo6DHA.2412@.TK2MSFTNGP09.phx.gbl...
> > > Hello,
> > >
> > > What is the best way to accomplish the following.
> > >
> > > 1) An ASP.NET program (consiting of one file somepage.aspx) receives
> about
> > > 25,000,000 requests pay day.
> > >
> > > 2) The requests come from a limited set of IP addresses.
> > >
> > > 3) How to count the total number of request from each IP address per
> day.
> > >
> > > SQL Server 2000 is used on the backend.
> > >
> > > Currently we used the following architecture:
> > >
> > > * Each request to somepage.aspx generates an INSERT into a LogTable1
> > > * There is a clustered index on the LogTable1 on the dateStamp field
> which
> > > is of the type smalldatetime
> > > * The dateStamp field has a default that sets it to the getdate()
> > > * At the end of each day at 12:01AM there is a simple query that runs
> and
> > > does a group by to count the number of requests from each IP in the
> given
> > > date range (past 24 hours). This query works great and takes only 2
> > minutes
> > > to run.
> > >
> > > Is there a better way to accomplish this without having to do INSERTS
> into
> > > the LogTable1 for each request?
> > >
> > > It would not work to have the ASP.NET program execute an UPDATE each
> time
> > to
> > > increment the total number of request, since this would cause LOTSSS
of
> > > locking in the database layer.
> > >
> > > Thanks in advance.
> > >
> > > Arsen
> > >
> > >
> >
> >
>|||what i have done is cache the last 15 minutes. the cache has the ipaddress,
the start of the 15 min interval, pagename, and number of hits during the
interval. as most users cluster their hits, this cuts down the number of
inserts.
i flush the cache every 15 minutes of when too large.
you can then get daily or hourly stats from the db with simple queries.
-- bruce (sqlwork.com)
"Arsen V." <arsen.NoSpamPlease@.emergency24.com> wrote in message
news:emdbHKo6DHA.2412@.TK2MSFTNGP09.phx.gbl...
> Hello,
> What is the best way to accomplish the following.
> 1) An ASP.NET program (consiting of one file somepage.aspx) receives about
> 25,000,000 requests pay day.
> 2) The requests come from a limited set of IP addresses.
> 3) How to count the total number of request from each IP address per day.
> SQL Server 2000 is used on the backend.
> Currently we used the following architecture:
> * Each request to somepage.aspx generates an INSERT into a LogTable1
> * There is a clustered index on the LogTable1 on the dateStamp field which
> is of the type smalldatetime
> * The dateStamp field has a default that sets it to the getdate()
> * At the end of each day at 12:01AM there is a simple query that runs and
> does a group by to count the number of requests from each IP in the given
> date range (past 24 hours). This query works great and takes only 2
minutes
> to run.
> Is there a better way to accomplish this without having to do INSERTS into
> the LogTable1 for each request?
> It would not work to have the ASP.NET program execute an UPDATE each time
to
> increment the total number of request, since this would cause LOTSSS of
> locking in the database layer.
> Thanks in advance.
> Arsen
>

Sunday, February 19, 2012

how to copy sql database?

Hi there
I make a database called "TEST" for the template in ms sql 2000 server, and
I want to run VB.net to create another database called "TEST_COPY" in same
sql 2000 server and I want to transfer anything the "TEST" has (like tables
with data, views,stored procedure, trigger, role etc), how can I make a copy
in VB.net?
Thanks
Tony
Tony,
If you want everything (as it seems you do), then the easiest (assuming that
you have the needed rights) is to issue the following commands.
BACKUP DATABASE TEST TO TestBackupFileName
RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
Russell Fields
"tony" <itdong@.hotmail.com> wrote in message
news:eFs$jYhhEHA.3476@.tk2msftngp13.phx.gbl...
> Hi there
> I make a database called "TEST" for the template in ms sql 2000 server,
and
> I want to run VB.net to create another database called "TEST_COPY" in same
> sql 2000 server and I want to transfer anything the "TEST" has (like
tables
> with data, views,stored procedure, trigger, role etc), how can I make a
copy
> in VB.net?
>
> Thanks
> Tony
>
|||Or you can just issue the update query command:
SELECT * INTO test_copy FROM test;
Regards.
|||I'M SORRY FOR THIS INFO, I THOUGHT YOU'RE REFERRING TO A TABLE.
"Jon Gonzales" wrote:

> Or you can just issue the update query command:
> SELECT * INTO test_copy FROM test;
> Regards.
|||Dear Russell
when I use this you suggested
BACKUP DATABASE TEST TO TestBackupFileName
RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
I change the first one to
BACKUP DATABASE TEST TO disk='C:\TestBackFileName'
and it is works
and then when I use second one,
RESTORE DATABASE TEST_COPY FROM disk='C:\TestBackFileName' WITH REPLACE
I got Error as follow:
Server: Msg 1834, Level 16, State 1, Line 1
The file 'C:\TEST.mdf' cannot be overwritten. It is being used by database
'TEST'.
Server: Msg 3156, Level 16, State 1, Line 1
File 'Store29_TEST_dat' cannot be restored to 'C:\TEST.mdf'. Use WITH MOVE
to identify a valid location for the file.
Server: Msg 1834, Level 16, State 1, Line 1
The file 'C:\TEST.ldf' cannot be overwritten. It is being used by database
'TEST'.
Server: Msg 3156, Level 16, State 1, Line 1
File 'Store29_TEST_log' cannot be restored to 'C:\TEST.ldf'. Use WITH MOVE
to identify a valid location for the file.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
When I use with move as follow:
RESTORE DATABASE TEST_COPY FROM disk ='C:\TestBackupFileName' with Recovery,
move 'TEST.mdf' to 'C:\TEST_COPY.mdf', move 'TEST.ldf' to 'C:\Test_copy.ldf'
I got other error as follow
Server: Msg 3234, Level 16, State 2, Line 1
Logical file 'TEST.mdf' is not part of database 'TEST_COPY'. Use RESTORE
FILELISTONLY to list the logical file names.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
How can I keep doing with the copy like you suggested?
Thanks
Tony
"Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
news:eJ$4fSihEHA.1964@.tk2msftngp13.phx.gbl...
> Tony,
> If you want everything (as it seems you do), then the easiest (assuming
that[vbcol=seagreen]
> you have the needed rights) is to issue the following commands.
> BACKUP DATABASE TEST TO TestBackupFileName
> RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
> Russell Fields
> "tony" <itdong@.hotmail.com> wrote in message
> news:eFs$jYhhEHA.3476@.tk2msftngp13.phx.gbl...
> and
same
> tables
> copy
>
|||tony,
Sorry that my shorthand answer was not specific enough.
You will also need to use the option (from the BOL):
MOVE 'logical_file_name' TO 'operating_system_file_name'
Specifies that the given logical_file_name should be moved to
operating_system_file_name. By default, the logical_file_name is restored to
its original location. If the RESTORE statement is used to copy a database
to the same or different server, the MOVE option may be needed to relocate
the database files and to avoid collisions with existing files. Each logical
file in the database can be specified in different MOVE statements.
This keeps the file from trying to overwrite the active database.
Russell Fields
"tony" <itdong@.hotmail.com> wrote in message
news:%23wQZHgthEHA.2812@.tk2msftngp13.phx.gbl...
> Dear Russell
> when I use this you suggested
> BACKUP DATABASE TEST TO TestBackupFileName
> RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
> I change the first one to
> BACKUP DATABASE TEST TO disk='C:\TestBackFileName'
> and it is works
> and then when I use second one,
> RESTORE DATABASE TEST_COPY FROM disk='C:\TestBackFileName' WITH REPLACE
> I got Error as follow:
> Server: Msg 1834, Level 16, State 1, Line 1
> The file 'C:\TEST.mdf' cannot be overwritten. It is being used by
database
> 'TEST'.
> Server: Msg 3156, Level 16, State 1, Line 1
> File 'Store29_TEST_dat' cannot be restored to 'C:\TEST.mdf'. Use WITH MOVE
> to identify a valid location for the file.
> Server: Msg 1834, Level 16, State 1, Line 1
> The file 'C:\TEST.ldf' cannot be overwritten. It is being used by
database
> 'TEST'.
> Server: Msg 3156, Level 16, State 1, Line 1
> File 'Store29_TEST_log' cannot be restored to 'C:\TEST.ldf'. Use WITH MOVE
> to identify a valid location for the file.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
> When I use with move as follow:
> RESTORE DATABASE TEST_COPY FROM disk ='C:\TestBackupFileName' with
Recovery,
> move 'TEST.mdf' to 'C:\TEST_COPY.mdf', move 'TEST.ldf' to
'C:\Test_copy.ldf'[vbcol=seagreen]
> I got other error as follow
> Server: Msg 3234, Level 16, State 2, Line 1
> Logical file 'TEST.mdf' is not part of database 'TEST_COPY'. Use RESTORE
> FILELISTONLY to list the logical file names.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
>
>
> How can I keep doing with the copy like you suggested?
> Thanks
> Tony
>
> "Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
> news:eJ$4fSihEHA.1964@.tk2msftngp13.phx.gbl...
> that
server,[vbcol=seagreen]
> same
a
>

how to copy sql database?

Hi there
I make a database called "TEST" for the template in ms sql 2000 server, and
I want to run VB.net to create another database called "TEST_COPY" in same
sql 2000 server and I want to transfer anything the "TEST" has (like tables
with data, views,stored procedure, trigger, role etc), how can I make a copy
in VB.net?
Thanks
TonyTony,
If you want everything (as it seems you do), then the easiest (assuming that
you have the needed rights) is to issue the following commands.
BACKUP DATABASE TEST TO TestBackupFileName
RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
Russell Fields
"tony" <itdong@.hotmail.com> wrote in message
news:eFs$jYhhEHA.3476@.tk2msftngp13.phx.gbl...
> Hi there
> I make a database called "TEST" for the template in ms sql 2000 server,
and
> I want to run VB.net to create another database called "TEST_COPY" in same
> sql 2000 server and I want to transfer anything the "TEST" has (like
tables
> with data, views,stored procedure, trigger, role etc), how can I make a
copy
> in VB.net?
>
> Thanks
> Tony
>|||Or you can just issue the update query command:
SELECT * INTO test_copy FROM test;
Regards.|||I'M SORRY FOR THIS INFO, I THOUGHT YOU'RE REFERRING TO A TABLE.
"Jon Gonzales" wrote:

> Or you can just issue the update query command:
> SELECT * INTO test_copy FROM test;
> Regards.|||Dear Russell
when I use this you suggested
BACKUP DATABASE TEST TO TestBackupFileName
RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
I change the first one to
BACKUP DATABASE TEST TO disk='C:\TestBackFileName'
and it is works
and then when I use second one,
RESTORE DATABASE TEST_COPY FROM disk='C:\TestBackFileName' WITH REPLACE
I got Error as follow:
Server: Msg 1834, Level 16, State 1, Line 1
The file 'C:\TEST.mdf' cannot be overwritten. It is being used by database
'TEST'.
Server: Msg 3156, Level 16, State 1, Line 1
File 'Store29_TEST_dat' cannot be restored to 'C:\TEST.mdf'. Use WITH MOVE
to identify a valid location for the file.
Server: Msg 1834, Level 16, State 1, Line 1
The file 'C:\TEST.ldf' cannot be overwritten. It is being used by database
'TEST'.
Server: Msg 3156, Level 16, State 1, Line 1
File 'Store29_TEST_log' cannot be restored to 'C:\TEST.ldf'. Use WITH MOVE
to identify a valid location for the file.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
---
When I use with move as follow:
RESTORE DATABASE TEST_COPY FROM disk ='C:\TestBackupFileName' with Recovery,
move 'TEST.mdf' to 'C:\TEST_COPY.mdf', move 'TEST.ldf' to 'C:\Test_copy.ldf'
I got other error as follow
Server: Msg 3234, Level 16, State 2, Line 1
Logical file 'TEST.mdf' is not part of database 'TEST_COPY'. Use RESTORE
FILELISTONLY to list the logical file names.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
How can I keep doing with the copy like you suggested?
Thanks
Tony
"Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
news:eJ$4fSihEHA.1964@.tk2msftngp13.phx.gbl...
> Tony,
> If you want everything (as it seems you do), then the easiest (assuming
that
> you have the needed rights) is to issue the following commands.
> BACKUP DATABASE TEST TO TestBackupFileName
> RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
> Russell Fields
> "tony" <itdong@.hotmail.com> wrote in message
> news:eFs$jYhhEHA.3476@.tk2msftngp13.phx.gbl...
> and
same[vbcol=seagreen]
> tables
> copy
>|||tony,
Sorry that my shorthand answer was not specific enough.
You will also need to use the option (from the BOL):
MOVE 'logical_file_name' TO 'operating_system_file_name'
Specifies that the given logical_file_name should be moved to
operating_system_file_name. By default, the logical_file_name is restored to
its original location. If the RESTORE statement is used to copy a database
to the same or different server, the MOVE option may be needed to relocate
the database files and to avoid collisions with existing files. Each logical
file in the database can be specified in different MOVE statements.
This keeps the file from trying to overwrite the active database.
Russell Fields
"tony" <itdong@.hotmail.com> wrote in message
news:%23wQZHgthEHA.2812@.tk2msftngp13.phx.gbl...
> Dear Russell
> when I use this you suggested
> BACKUP DATABASE TEST TO TestBackupFileName
> RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
> I change the first one to
> BACKUP DATABASE TEST TO disk='C:\TestBackFileName'
> and it is works
> and then when I use second one,
> RESTORE DATABASE TEST_COPY FROM disk='C:\TestBackFileName' WITH REPLACE
> I got Error as follow:
> Server: Msg 1834, Level 16, State 1, Line 1
> The file 'C:\TEST.mdf' cannot be overwritten. It is being used by
database
> 'TEST'.
> Server: Msg 3156, Level 16, State 1, Line 1
> File 'Store29_TEST_dat' cannot be restored to 'C:\TEST.mdf'. Use WITH MOVE
> to identify a valid location for the file.
> Server: Msg 1834, Level 16, State 1, Line 1
> The file 'C:\TEST.ldf' cannot be overwritten. It is being used by
database
> 'TEST'.
> Server: Msg 3156, Level 16, State 1, Line 1
> File 'Store29_TEST_log' cannot be restored to 'C:\TEST.ldf'. Use WITH MOVE
> to identify a valid location for the file.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
> ---
> When I use with move as follow:
> RESTORE DATABASE TEST_COPY FROM disk ='C:\TestBackupFileName' with
Recovery,
> move 'TEST.mdf' to 'C:\TEST_COPY.mdf', move 'TEST.ldf' to
'C:\Test_copy.ldf'
> I got other error as follow
> Server: Msg 3234, Level 16, State 2, Line 1
> Logical file 'TEST.mdf' is not part of database 'TEST_COPY'. Use RESTORE
> FILELISTONLY to list the logical file names.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
>
>
> How can I keep doing with the copy like you suggested?
> Thanks
> Tony
>
> "Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
> news:eJ$4fSihEHA.1964@.tk2msftngp13.phx.gbl...
> that
server,[vbcol=seagreen]
> same
a[vbcol=seagreen]
>

how to copy sql database?

Hi there
I make a database called "TEST" for the template in ms sql 2000 server, and
I want to run VB.net to create another database called "TEST_COPY" in same
sql 2000 server and I want to transfer anything the "TEST" has (like tables
with data, views,stored procedure, trigger, role etc), how can I make a copy
in VB.net?
Thanks
TonyTony,
If you want everything (as it seems you do), then the easiest (assuming that
you have the needed rights) is to issue the following commands.
BACKUP DATABASE TEST TO TestBackupFileName
RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
Russell Fields
"tony" <itdong@.hotmail.com> wrote in message
news:eFs$jYhhEHA.3476@.tk2msftngp13.phx.gbl...
> Hi there
> I make a database called "TEST" for the template in ms sql 2000 server,
and
> I want to run VB.net to create another database called "TEST_COPY" in same
> sql 2000 server and I want to transfer anything the "TEST" has (like
tables
> with data, views,stored procedure, trigger, role etc), how can I make a
copy
> in VB.net?
>
> Thanks
> Tony
>|||Or you can just issue the update query command:
SELECT * INTO test_copy FROM test;
Regards.|||I'M SORRY FOR THIS INFO, I THOUGHT YOU'RE REFERRING TO A TABLE.
"Jon Gonzales" wrote:
> Or you can just issue the update query command:
> SELECT * INTO test_copy FROM test;
> Regards.|||Dear Russell
when I use this you suggested
BACKUP DATABASE TEST TO TestBackupFileName
RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
I change the first one to
BACKUP DATABASE TEST TO disk='C:\TestBackFileName'
and it is works
and then when I use second one,
RESTORE DATABASE TEST_COPY FROM disk='C:\TestBackFileName' WITH REPLACE
I got Error as follow:
Server: Msg 1834, Level 16, State 1, Line 1
The file 'C:\TEST.mdf' cannot be overwritten. It is being used by database
'TEST'.
Server: Msg 3156, Level 16, State 1, Line 1
File 'Store29_TEST_dat' cannot be restored to 'C:\TEST.mdf'. Use WITH MOVE
to identify a valid location for the file.
Server: Msg 1834, Level 16, State 1, Line 1
The file 'C:\TEST.ldf' cannot be overwritten. It is being used by database
'TEST'.
Server: Msg 3156, Level 16, State 1, Line 1
File 'Store29_TEST_log' cannot be restored to 'C:\TEST.ldf'. Use WITH MOVE
to identify a valid location for the file.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
---
When I use with move as follow:
RESTORE DATABASE TEST_COPY FROM disk ='C:\TestBackupFileName' with Recovery,
move 'TEST.mdf' to 'C:\TEST_COPY.mdf', move 'TEST.ldf' to 'C:\Test_copy.ldf'
I got other error as follow
Server: Msg 3234, Level 16, State 2, Line 1
Logical file 'TEST.mdf' is not part of database 'TEST_COPY'. Use RESTORE
FILELISTONLY to list the logical file names.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
How can I keep doing with the copy like you suggested?
Thanks
Tony
"Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
news:eJ$4fSihEHA.1964@.tk2msftngp13.phx.gbl...
> Tony,
> If you want everything (as it seems you do), then the easiest (assuming
that
> you have the needed rights) is to issue the following commands.
> BACKUP DATABASE TEST TO TestBackupFileName
> RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
> Russell Fields
> "tony" <itdong@.hotmail.com> wrote in message
> news:eFs$jYhhEHA.3476@.tk2msftngp13.phx.gbl...
> > Hi there
> >
> > I make a database called "TEST" for the template in ms sql 2000 server,
> and
> > I want to run VB.net to create another database called "TEST_COPY" in
same
> > sql 2000 server and I want to transfer anything the "TEST" has (like
> tables
> > with data, views,stored procedure, trigger, role etc), how can I make a
> copy
> > in VB.net?
> >
> >
> > Thanks
> >
> > Tony
> >
> >
>|||tony,
Sorry that my shorthand answer was not specific enough.
You will also need to use the option (from the BOL):
MOVE 'logical_file_name' TO 'operating_system_file_name'
Specifies that the given logical_file_name should be moved to
operating_system_file_name. By default, the logical_file_name is restored to
its original location. If the RESTORE statement is used to copy a database
to the same or different server, the MOVE option may be needed to relocate
the database files and to avoid collisions with existing files. Each logical
file in the database can be specified in different MOVE statements.
This keeps the file from trying to overwrite the active database.
Russell Fields
"tony" <itdong@.hotmail.com> wrote in message
news:%23wQZHgthEHA.2812@.tk2msftngp13.phx.gbl...
> Dear Russell
> when I use this you suggested
> BACKUP DATABASE TEST TO TestBackupFileName
> RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
> I change the first one to
> BACKUP DATABASE TEST TO disk='C:\TestBackFileName'
> and it is works
> and then when I use second one,
> RESTORE DATABASE TEST_COPY FROM disk='C:\TestBackFileName' WITH REPLACE
> I got Error as follow:
> Server: Msg 1834, Level 16, State 1, Line 1
> The file 'C:\TEST.mdf' cannot be overwritten. It is being used by
database
> 'TEST'.
> Server: Msg 3156, Level 16, State 1, Line 1
> File 'Store29_TEST_dat' cannot be restored to 'C:\TEST.mdf'. Use WITH MOVE
> to identify a valid location for the file.
> Server: Msg 1834, Level 16, State 1, Line 1
> The file 'C:\TEST.ldf' cannot be overwritten. It is being used by
database
> 'TEST'.
> Server: Msg 3156, Level 16, State 1, Line 1
> File 'Store29_TEST_log' cannot be restored to 'C:\TEST.ldf'. Use WITH MOVE
> to identify a valid location for the file.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
> ---
> When I use with move as follow:
> RESTORE DATABASE TEST_COPY FROM disk ='C:\TestBackupFileName' with
Recovery,
> move 'TEST.mdf' to 'C:\TEST_COPY.mdf', move 'TEST.ldf' to
'C:\Test_copy.ldf'
> I got other error as follow
> Server: Msg 3234, Level 16, State 2, Line 1
> Logical file 'TEST.mdf' is not part of database 'TEST_COPY'. Use RESTORE
> FILELISTONLY to list the logical file names.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
>
>
> How can I keep doing with the copy like you suggested?
> Thanks
> Tony
>
> "Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
> news:eJ$4fSihEHA.1964@.tk2msftngp13.phx.gbl...
> > Tony,
> >
> > If you want everything (as it seems you do), then the easiest (assuming
> that
> > you have the needed rights) is to issue the following commands.
> >
> > BACKUP DATABASE TEST TO TestBackupFileName
> >
> > RESTORE DATABASE TEST_COPY FROM TestBackupFileName WITH REPLACE
> >
> > Russell Fields
> > "tony" <itdong@.hotmail.com> wrote in message
> > news:eFs$jYhhEHA.3476@.tk2msftngp13.phx.gbl...
> > > Hi there
> > >
> > > I make a database called "TEST" for the template in ms sql 2000
server,
> > and
> > > I want to run VB.net to create another database called "TEST_COPY" in
> same
> > > sql 2000 server and I want to transfer anything the "TEST" has (like
> > tables
> > > with data, views,stored procedure, trigger, role etc), how can I make
a
> > copy
> > > in VB.net?
> > >
> > >
> > > Thanks
> > >
> > > Tony
> > >
> > >
> >
> >
>

How to copy db to production server

I've developing a small asp.net app that is using SQL Server (developer
edition on my PC). I am ready to deploy my app on my web server/space (that
I am renting from a hosting company) for further testing before we go live.
I need to copy my database from my sql server instance to a sql server
instance at my host's facility. I am able to connect to that server via
enterprise manager. Is the Copy Database Wizard the way to go here, or
should export a script and then run that on the web sql server instance? I
do not have much data in my db, so I don't have to copy the data, but it
would be nice.
Thanks!epigram (nospam@.spammy.com) writes:
> I've developing a small asp.net app that is using SQL Server (developer
> edition on my PC). I am ready to deploy my app on my web server/space
> (that I am renting from a hosting company) for further testing before we
> go live. I need to copy my database from my sql server instance to a sql
> server instance at my host's facility. I am able to connect to that
> server via enterprise manager. Is the Copy Database Wizard the way to
> go here, or should export a script and then run that on the web sql
> server instance? I do not have much data in my db, so I don't have to
> copy the data, but it would be nice.
I would put all code under version control, and that includes any data
you may have tables that you pre-load. (Fixed lookup tables and such).
Then I would install the database on the production server from those
scripts.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp|||You can also consider to use AgileInfoSoftware DataStudio to copy your
database to production server. For the same platform migration (From SQL
Server to SQL Server), it can migrate all supported objects. If you need to
migrate to different database (for instance, from Oracle to SQL Server),
then all tables/views/constraints/indexes/data are migrated, but not
database specific objects, such as function/procedure/packages.
You can download trial version at http://www.agileinfollc.com
John King
AgileInfoSoftware
http://www.agileinfollc.com
"epigram" <nospam@.spammy.com> wrote in message
news:1124828227.3cd98101b03ff015d3bf26ba65b37623@.bubbanews...
> I've developing a small asp.net app that is using SQL Server (developer
> edition on my PC). I am ready to deploy my app on my web server/space
> (that I am renting from a hosting company) for further testing before we
> go live. I need to copy my database from my sql server instance to a sql
> server instance at my host's facility. I am able to connect to that
> server via enterprise manager. Is the Copy Database Wizard the way to go
> here, or should export a script and then run that on the web sql server
> instance? I do not have much data in my db, so I don't have to copy the
> data, but it would be nice.
> Thanks!
>

How to copy db to production server

I've developing a small asp.net app that is using SQL Server (developer
edition on my PC). I am ready to deploy my app on my web server/space (that
I am renting from a hosting company) for further testing before we go live.
I need to copy my database from my sql server instance to a sql server
instance at my host's facility. I am able to connect to that server via
enterprise manager. Is the Copy Database Wizard the way to go here, or
should export a script and then run that on the web sql server instance? I
do not have much data in my db, so I don't have to copy the data, but it
would be nice.
Thanks!
epigram (nospam@.spammy.com) writes:
> I've developing a small asp.net app that is using SQL Server (developer
> edition on my PC). I am ready to deploy my app on my web server/space
> (that I am renting from a hosting company) for further testing before we
> go live. I need to copy my database from my sql server instance to a sql
> server instance at my host's facility. I am able to connect to that
> server via enterprise manager. Is the Copy Database Wizard the way to
> go here, or should export a script and then run that on the web sql
> server instance? I do not have much data in my db, so I don't have to
> copy the data, but it would be nice.
I would put all code under version control, and that includes any data
you may have tables that you pre-load. (Fixed lookup tables and such).
Then I would install the database on the production server from those
scripts.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
|||You can also consider to use AgileInfoSoftware DataStudio to copy your
database to production server. For the same platform migration (From SQL
Server to SQL Server), it can migrate all supported objects. If you need to
migrate to different database (for instance, from Oracle to SQL Server),
then all tables/views/constraints/indexes/data are migrated, but not
database specific objects, such as function/procedure/packages.
You can download trial version at http://www.agileinfollc.com
John King
AgileInfoSoftware
http://www.agileinfollc.com
"epigram" <nospam@.spammy.com> wrote in message
news:1124828227.3cd98101b03ff015d3bf26ba65b37623@.b ubbanews...
> I've developing a small asp.net app that is using SQL Server (developer
> edition on my PC). I am ready to deploy my app on my web server/space
> (that I am renting from a hosting company) for further testing before we
> go live. I need to copy my database from my sql server instance to a sql
> server instance at my host's facility. I am able to connect to that
> server via enterprise manager. Is the Copy Database Wizard the way to go
> here, or should export a script and then run that on the web sql server
> instance? I do not have much data in my db, so I don't have to copy the
> data, but it would be nice.
> Thanks!
>

How to copy db to production server

I've developing a small asp.net app that is using SQL Server (developer
edition on my PC). I am ready to deploy my app on my web server/space (that
I am renting from a hosting company) for further testing before we go live.
I need to copy my database from my sql server instance to a sql server
instance at my host's facility. I am able to connect to that server via
enterprise manager. Is the Copy Database Wizard the way to go here, or
should export a script and then run that on the web sql server instance? I
do not have much data in my db, so I don't have to copy the data, but it
would be nice.
Thanks!epigram (nospam@.spammy.com) writes:
> I've developing a small asp.net app that is using SQL Server (developer
> edition on my PC). I am ready to deploy my app on my web server/space
> (that I am renting from a hosting company) for further testing before we
> go live. I need to copy my database from my sql server instance to a sql
> server instance at my host's facility. I am able to connect to that
> server via enterprise manager. Is the Copy Database Wizard the way to
> go here, or should export a script and then run that on the web sql
> server instance? I do not have much data in my db, so I don't have to
> copy the data, but it would be nice.
I would put all code under version control, and that includes any data
you may have tables that you pre-load. (Fixed lookup tables and such).
Then I would install the database on the production server from those
scripts.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||You can also consider to use AgileInfoSoftware DataStudio to copy your
database to production server. For the same platform migration (From SQL
Server to SQL Server), it can migrate all supported objects. If you need to
migrate to different database (for instance, from Oracle to SQL Server),
then all tables/views/constraints/indexes/data are migrated, but not
database specific objects, such as function/procedure/packages.
You can download trial version at http://www.agileinfollc.com
John King
AgileInfoSoftware
http://www.agileinfollc.com
"epigram" <nospam@.spammy.com> wrote in message
news:1124828227. 3cd98101b03ff015d3bf26ba65b37623@.bubbane
ws...
> I've developing a small asp.net app that is using SQL Server (developer
> edition on my PC). I am ready to deploy my app on my web server/space
> (that I am renting from a hosting company) for further testing before we
> go live. I need to copy my database from my sql server instance to a sql
> server instance at my host's facility. I am able to connect to that
> server via enterprise manager. Is the Copy Database Wizard the way to go
> here, or should export a script and then run that on the web sql server
> instance? I do not have much data in my db, so I don't have to copy the
> data, but it would be nice.
> Thanks!
>