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

Thursday, March 29, 2012

Get back data from Reports

I have just started working with RS 2005 and was wondering if / how I can do the following.

I created an asp.net website that has a report viewer to show my reports on the web.
In addition there is a page that lists all of the reports a user has access to, which is pretty much a series of links:

Report 1
Report 2
Report 3
.....

Now in my reports I generally create a grand total of one of the column and was wondering if there was some way to get that information back into an asp page, ie:

Report 1 - $125,713
Report 2 - ($23,111)
Report 3 - $1,762,142

I was thinking if there was some way to send a parameter to the report like Summary=True which would tell it to just return a XML bit of data holding the total for that report (Anything will work, doesn't have to be XML). So the page with the report links would call each of the reports.

I realize that it would probably be possible to do this through a stored procedure, but that would just create another point of maintenace. Instead I could create some function in all of my reports and have a standardized way of doing this so my webserver or database wouldnt have to be updated all the time.

Thanks, and let me know if there is any other information I can provide to make this clearer.

Try using the XML renderer. You will get a "report" which is really just an XML stream with the data. You can then XPath into it to get the values you are interested in.|||

Sounds promising. Being rather new to reports, are there any pages you can think of off hand that provide examples or explanations?

Get a SQL Backup Folder Path in asp.net

Hi

Anyone knows , get a SQL Backup Folder Path in asp.net.Some Systems it displayed like D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup and some Systems like E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup and etc. i need to get a path for backup programmatically.Please help me.

Tamil

You can back up the databse to any location you'd like. You specify the path when you back up the DB.

sql

Get a return value when calling a SP from within ASP

I'm trying to get a return value (MyResult) from a stored procedure
that's called from within an ASP page. Both the codes in the Stored
Procedure and in the ASP page are rather simple and straightforward.
Any help available?
The error code says:
Microsoft VBScript compilation error '800a03ee'
Expected ')'
/ics/test1.asp, line 23
Set rs = ADODBCon.Execute(sSql, out MyResult)
--^
CREATE PROCEDURE usp_test @.Input int, @.Result int OUTPUT AS
set @.Result = 2 * @.Input
GO
---
<HTML>
<HEAD><TITLE>test</TITLE></HEAD>
<BODY>
<%
Set ADODBCon = Server.CreateObject("ADODB.Connection")
Dim StrConn, rs, MyInput, MyResult
MyInput = 123
ADODBCon.Provider = "SQLOLEDB"
strConn = "Data Source=MySQLServer;"
strConn = strConn & "Initial Catalog=MyDatabase;"
strConn = strConn & "User Id=JohnD;"
strConn = strConn & "Password=MyPwd;"
ADODBCon.Connectionstring = strConn
ADODBCon.open
sSql = "usp_test " & MyInput
Set rs = ADODBCon.Execute(sSql, out MyResult)
%>
</BODY>
</HTML>"ab" <absmienk@.hotmail.com> wrote in message
news:1154434778.587929.301980@.b28g2000cwb.googlegroups.com...
> I'm trying to get a return value (MyResult) from a stored procedure
> that's called from within an ASP page. Both the codes in the Stored
> Procedure and in the ASP page are rather simple and straightforward.
> Any help available?
>
TM for your R-ing pleasure:
Calling a Stored Procedure with a Command
http://windowssdk.msdn.microsoft.co...y/ms676516.aspx
David|||ab,
Use a command object instead.
How to call SQL Server stored procedures from ASP
http://support.microsoft.com/kb/q164485/
AMB
"ab" wrote:

> I'm trying to get a return value (MyResult) from a stored procedure
> that's called from within an ASP page. Both the codes in the Stored
> Procedure and in the ASP page are rather simple and straightforward.
> Any help available?
>
> The error code says:
> Microsoft VBScript compilation error '800a03ee'
> Expected ')'
> /ics/test1.asp, line 23
> Set rs = ADODBCon.Execute(sSql, out MyResult)
> --^
>
> CREATE PROCEDURE usp_test @.Input int, @.Result int OUTPUT AS
> set @.Result = 2 * @.Input
> GO
> ---
> <HTML>
> <HEAD><TITLE>test</TITLE></HEAD>
> <BODY>
> <%
> Set ADODBCon = Server.CreateObject("ADODB.Connection")
> Dim StrConn, rs, MyInput, MyResult
> MyInput = 123
> ADODBCon.Provider = "SQLOLEDB"
> strConn = "Data Source=MySQLServer;"
> strConn = strConn & "Initial Catalog=MyDatabase;"
> strConn = strConn & "User Id=JohnD;"
> strConn = strConn & "Password=MyPwd;"
> ADODBCon.Connectionstring = strConn
> ADODBCon.open
> sSql = "usp_test " & MyInput
> Set rs = ADODBCon.Execute(sSql, out MyResult)
> %>
> </BODY>
> </HTML>
>|||Thanks david, it worked.|||Alejandro, thank you. It worked.

Get a return value when calling a SP from within ASP

I'm trying to get a return value (MyResult) from a stored procedure
that's called from within an ASP page. Both the codes in the Stored
Procedure and in the ASP page are rather simple and straightforward.
Any help available?
The error code says:
Microsoft VBScript compilation error '800a03ee'
Expected ')'
/ics/test1.asp, line 23
Set rs = ADODBCon.Execute(sSql, out MyResult)
--^
CREATE PROCEDURE usp_test @.Input int, @.Result int OUTPUT AS
set @.Result = 2 * @.Input
GO
---
&

test"ab" <absmienk@.hotmail.com> wrote in message
news:1154434778.587929.301980@.b28g2000cwb.googlegroups.com...
> I'm trying to get a return value (MyResult) from a stored procedure
> that's called from within an ASP page. Both the codes in the Stored
> Procedure and in the ASP page are rather simple and straightforward.
> Any help available?
>
TM for your R-ing pleasure:
Calling a Stored Procedure with a Command
http://windowssdk.msdn.microsoft.com/en-us/library/ms676516.aspx
David|||ab,
Use a command object instead.
How to call SQL Server stored procedures from ASP
http://support.microsoft.com/kb/q164485/
AMB
"ab" wrote:
> I'm trying to get a return value (MyResult) from a stored procedure
> that's called from within an ASP page. Both the codes in the Stored
> Procedure and in the ASP page are rather simple and straightforward.
> Any help available?
>
> The error code says:
> Microsoft VBScript compilation error '800a03ee'
> Expected ')'
> /ics/test1.asp, line 23
> Set rs = ADODBCon.Execute(sSql, out MyResult)
> --^
>
> CREATE PROCEDURE usp_test @.Input int, @.Result int OUTPUT AS
> set @.Result = 2 * @.Input
> GO
> ---
> &

> test
>
> Set ADODBCon = Server.CreateObject("ADODB.Connection")
> Dim StrConn, rs, MyInput, MyResult
> MyInput = 123
> ADODBCon.Provider = "SQLOLEDB"
> strConn = "Data Source=MySQLServer;"
> strConn = strConn & "Initial Catalog=MyDatabase;"
> strConn = strConn & "User Id=JohnD;"
> strConn = strConn & "Password=MyPwd;"
> ADODBCon.Connectionstring = strConn
> ADODBCon.open
> sSql = "usp_test " & MyInput
> Set rs = ADODBCon.Execute(sSql, out MyResult)
> %>
>
>

>|||Thanks david, it worked.|||Alejandro, thank you. It worked.

Tuesday, March 27, 2012

Get > Array > Split > Listbox

Hi everyone,

having some problemsBasically, using ASP.NET 2.0 and here is my problem,

Get data from tablePut into arraySplit where there is a +remove +'sassign to listbox to give a list of everything in that tableThe + split the courses, so in my Order table I have A + B + C etc and I want all of the different options in a list box (note different records have different entries it isn't always a b c)I am testing my code, here is what I got

     Public Sub TitleChange(ByVal Sender As Object, ByVal E As EventArgs)
Try
Dim DBConn As SqlConnection
Dim DSPageData As DataSet = New DataSet()
Dim VarTxtAOE As String
DBConn = New SqlConnection("Server=SD02;Initial Catalog=WhoGetsWhat;Persist Security Info=True;UID=x;Password=XXX")
'Dim DBDataAdapter As SqlDataAdapter
DBDataAdapter = New SqlDataAdapter("Select AOE FROM TBL_Role WHERE Title = @.ddlTitle", DBConn)
DBDataAdapter.SelectCommand.Parameters.Add("@.ddlTitle", SqlDbType.NVarChar)
DBDataAdapter.SelectCommand.Parameters("@.ddlTitle").Value = TitleDropDown.SelectedValue
DBDataAdapter.Fill(DSPageData, "Courses")
'Need to find out what this rows business is about whats the number about? and am I doing it correct?
'txtAOE.Text = DSPageData.Tables("Courses").Rows(0).Item("AOE")
'txtAOE.Items.Add(New ListItem(DSPageData.Tables(0).Rows(0).Item("AOE")))

VarTxtAOE = DSPageData.Tables("Courses").Rows(0).Item("AOE")
Dim VarArray() As String = VarTxtAOE.Split("+")
Response.Write(VarArray())
txtAOE.DataSource = VarArray()
txtAOE.DataBind()

'Response.Write(test)
'ListBox1.DataSource = test

'Response.Write(VarArray)

Catch TheException As Exception
lblerror.Text = "Error occurred: " & TheException.ToString()
End Try
End Sub

My response.Write works correctly, but my list box doesn't, also I don't want to say which bit of the array like I have done using 1, I just want to display the whole array in my list box. I am not worrying about removing the +'s at the minute, just splitting my data and putting each section into a listboxMaybe I am going about this the wrong way, but I have been trying a lot of different things and its hard to find any help

ThanksChris

You need to set the DataTextField and DataValueField properties of the ListBox and then call it's DataBind() function.

|||

Ok, so I put this in

td style="width: 40%">
AOE<br />
<asp:ListBox ID="txtAOE" runat="server" Width="200px" DataTextField="AOE" DataValueField="AOE" /></td>


but should I use AOE in my Datatext/valueField or VarArray? I mean in my data bits I have AOE in my DataSet but I want it in an array to split the data!

VarTxtAOE = DSPageData.Tables("Courses").Rows(0).Item("AOE")
Dim VarArray() As String = VarTxtAOE.Split("+")
Response.Write(VarArray(0))
txtAOE.DataSource = VarArray(0)
txtAOE.DataBind()


should I even put it in an array, is there an easier way to cut up my returned value and put it in a listbox?

Thanks
Chris

|||

I am thinking maybe I need to do a loop to loop through the array to put each entry in the listbox, or maybe just there is an easy way with the datasource to put all the different values in the listbox?

Chris

|||

Hi,

You mentioned "My response.Write works correctly, but my list box doesn't". So does it indicate that you can get the formated string which is going to be splitted successfully?

Suppose we can get a+b+c+d, so the array would be array[0]=a, array[1]=b, array[2]=c, array[3]=d. If you can get the array successfully, then the problem has changed to how to bind the array to you List Box control. See the following sample.

for (int i = 0; i < array.Length; i++) { ListItem li =new ListItem(); li.Text = array[i].ToString(); li.Value = array[i].ToString();this.ListBox1.Items.Add(li);}Then you can useListBox1.SelectedValue.ToString() to get the value you selected.
Hope that helps. Thanks.
|||

Hi,

Thanks for that reply, that does look like C# to me however but I will try to convert to VB.Net.

Yes I can get a piece of data out of the array but I have to specify the number so say response.write(vararray(1)) but your code looks about right looping though each one and assigning it to the listbox


Thanks
Chris

|||

:D

VarDS = DSPageData.Tables("Courses").Rows(0).Item("AOE")
Dim VarArray() As String = VarDS.Split("+")

Dim i As Integer
For i = 0 To VarArray.Length - 1

Dim li As New ListItem()
li.Text = VarArray(i).ToString()
li.Value = VarArray(i).ToString()
Me.txtAOE.Items.Add(li)
Next i

Perfecto!! It works, my only issue is now, I need to do this again and again so how do I clear out my array because I will have this one, the next block will be for another list box, different values but same process, but it gives me a warning

Number of indices is less than the number of dimensions of the indexed array

I am guessing that after this one, I just need to clear the VarArray() then I can run the 2nd block, but how do I clear the array, unless that error means something else?

Thanks
Chris

|||

I have been trying but I still have the issue outlined above, I'll mention again

I need to do this again and again so how do I clear out my arraybecause I will have this one, the next block will be for another listbox, different values but same process, but it gives me a warning

Number of indices is less than the number of dimensions of the indexed array

Iam guessing that after this one, I just need to clear the VarArray()then I can run the 2nd block, but how do I clear the array, unless thaterror means something else?

Anyone know how I can get around this? I guess I could create multiple arrays as a temp to let it work?

Thanks

Chris


|||
Hi,
Actually you can useYourarray=null to clear your array. See the sample below:
  
Dim strAs String ="ssdfdsfds%sdfdsfdf%dgbtb%"Dim myarrAs String() = str.Split("%"C)For iAs Integer = 0To myarr.Length - 1Response.Write(myarr(i).ToString())NextResponse.Write("</br>")myarr =NothingDim str2As String ="3453534%567657657%24332%"myarr = str2.Split("%"C)For iAs Integer = 0To myarr.Length - 1Response.Write(myarr(i).ToString())Next
Hope that helps. Thanks.
|||

Worked like a treat, I didn't see the Nothing when I was looking around for a way to do it, so thats a useful one to know, thanks for all your help. After all this I should now be able to construct my own loops to set the hight of the list box :)

Thanks
Chris

Gerating a xml file from oracle 9i in a asp program

Hi, is any of the user of that list works with Oracle9i ? because i need to generate xml file from a intranet asp site ... so i don't know where to find information ...
In fact, i want to make a xml file from a sql reqest from oracle in a asp program ...is someone did that ? how i can read a recorset if i use sqlxml of oracle ?
thanks in advance
cheers
jp
With SQL Server you could use the FOR XML clause to get the data out in XML
format. If you need help for the same, with Oracle, then please post this to
an Oracle newsgroup.
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"Jean-Paul" <Jean-Paul@.discussions.microsoft.com> wrote in message
news:20812732-5D8B-4374-8383-763B56F688AD@.microsoft.com...
Hi, is any of the user of that list works with Oracle9i ? because i need to
generate xml file from a intranet asp site ... so i don't know where to find
information ...
In fact, i want to make a xml file from a sql reqest from oracle in a asp
program ...is someone did that ? how i can read a recorset if i use sqlxml
of oracle ?
thanks in advance
cheers
jp

Monday, March 26, 2012

genral network error on .net framework 1.1 using system.data.sqlclient in asp .net

hi i am using asp .net 1.1

i have deployed my application on server where sql server 2005 exists but if i try to connect to sql server from my development machine then it is not connecting and gives me error when

conn.open()

in my sql server it is windows authentication.

the error is general network error check network docs.

i have tried timeout=0 and pooling=false

but neither works please answer.

what should my connection string.

you're in the wrong forum for this question. this forum is for SQL Server 2005 Mobile Edition. I'd recommend one of the ASP.NET MSDN Forums for this question.

Darren

Friday, March 23, 2012

Generating SQL Script

Hi All
I have SQL Data Base . I am using asp application to access this Data Base.
I want to create a script to generate Data Base on other machines. I have
some data in that Data Base, which I required to run my application.
So the final SCRIPT should contain all relations, default values ,
Identities and Data.
Which method you advise to achieve these.
Kind Regards
Here is an article I wrote about generating SQL Server scripts. Hopefully
this will provide you with enough information to help you determine the best
way to generate your script.
http://www.dbazine.com/larsen4.shtml
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> Hi All
> I have SQL Data Base . I am using asp application to access this Data
Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>
|||Thanks for your reply.
I tried using enterprise manager but its not creating script for data in the
table, only creating script for table.
Kind Regards
"Gregory A. Larsen" <greg.larsen@.netzero.com> wrote in message
news:ubhT35CaEHA.3888@.TK2MSFTNGP10.phx.gbl...
> Here is an article I wrote about generating SQL Server scripts. Hopefully
> this will provide you with enough information to help you determine the
best
> way to generate your script.
> http://www.dbazine.com/larsen4.shtml
> --
> ----
--
> ----
--[vbcol=seagreen]
> --
> Need SQL Server Examples check out my website at
> http://www.geocities.com/sqlserverexamples
> "F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
> news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> Base.
have
>
|||Gregory's article shows you how to generate scripts for objects. One thing
to remember is SQL Server Enterprise Manager or DMO have no capabilities for
scripting the data in the form of INSERT statements.
I wrote a procedure to script data as insert statements, and it can be found
at: http://vyaskn.tripod.com/code.htm#inserts
Alternatively, to move entire database, look up BACKUP/RESTORE and attaching
and detaching databases in SQL Server Books Online.
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> Hi All
> I have SQL Data Base . I am using asp application to access this Data
Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>
|||Sorry, my methods don't copy the data.
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:Oa6i3HDaEHA.2016@.TK2MSFTNGP09.phx.gbl...
> Thanks for your reply.
> I tried using enterprise manager but its not creating script for data in
the[vbcol=seagreen]
> table, only creating script for table.
> Kind Regards
>
>
> "Gregory A. Larsen" <greg.larsen@.netzero.com> wrote in message
> news:ubhT35CaEHA.3888@.TK2MSFTNGP10.phx.gbl...
Hopefully
> best
> ----
> --
> ----
> --
> have
>
|||Check out the free data and schema scripter from Innovartis - the makers of DB Ghost. www.dbghost.com
"F@.yy@.Z" wrote:

> Hi All
> I have SQL Data Base . I am using asp application to access this Data Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>
|||Try http://www.sqlscripter.com to script your data.
All types are supported: Insert, Update, Delete + Combinations.
It's free.
Thomas
"F@.yy@.Z" wrote:

> Hi All
> I have SQL Data Base . I am using asp application to access this Data Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>
sql

Generating SQL Script

Hi All
I have SQL Data Base . I am using asp application to access this Data Base.
I want to create a script to generate Data Base on other machines. I have
some data in that Data Base, which I required to run my application.
So the final SCRIPT should contain all relations, default values ,
Identities and Data.
Which method you advise to achieve these.
Kind RegardsHere is an article I wrote about generating SQL Server scripts. Hopefully
this will provide you with enough information to help you determine the best
way to generate your script.
http://www.dbazine.com/larsen4.shtml
--
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> Hi All
> I have SQL Data Base . I am using asp application to access this Data
Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>|||Thanks for your reply.
I tried using enterprise manager but its not creating script for data in the
table, only creating script for table.
Kind Regards
"Gregory A. Larsen" <greg.larsen@.netzero.com> wrote in message
news:ubhT35CaEHA.3888@.TK2MSFTNGP10.phx.gbl...
> Here is an article I wrote about generating SQL Server scripts. Hopefully
> this will provide you with enough information to help you determine the
best
> way to generate your script.
> http://www.dbazine.com/larsen4.shtml
> --
> ----
--
> ----
--
> --
> Need SQL Server Examples check out my website at
> http://www.geocities.com/sqlserverexamples
> "F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
> news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> > Hi All
> >
> > I have SQL Data Base . I am using asp application to access this Data
> Base.
> >
> > I want to create a script to generate Data Base on other machines. I
have
> > some data in that Data Base, which I required to run my application.
> >
> > So the final SCRIPT should contain all relations, default values ,
> > Identities and Data.
> >
> > Which method you advise to achieve these.
> >
> >
> > Kind Regards
> >
> >
> >
> >
> >
>|||Gregory's article shows you how to generate scripts for objects. One thing
to remember is SQL Server Enterprise Manager or DMO have no capabilities for
scripting the data in the form of INSERT statements.
I wrote a procedure to script data as insert statements, and it can be found
at: http://vyaskn.tripod.com/code.htm#inserts
Alternatively, to move entire database, look up BACKUP/RESTORE and attaching
and detaching databases in SQL Server Books Online.
--
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> Hi All
> I have SQL Data Base . I am using asp application to access this Data
Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>|||Sorry, my methods don't copy the data.
--
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:Oa6i3HDaEHA.2016@.TK2MSFTNGP09.phx.gbl...
> Thanks for your reply.
> I tried using enterprise manager but its not creating script for data in
the
> table, only creating script for table.
> Kind Regards
>
>
> "Gregory A. Larsen" <greg.larsen@.netzero.com> wrote in message
> news:ubhT35CaEHA.3888@.TK2MSFTNGP10.phx.gbl...
> > Here is an article I wrote about generating SQL Server scripts.
Hopefully
> > this will provide you with enough information to help you determine the
> best
> > way to generate your script.
> >
> > http://www.dbazine.com/larsen4.shtml
> >
> > --
> >
> ----
> --
> ----
> --
> > --
> >
> > Need SQL Server Examples check out my website at
> > http://www.geocities.com/sqlserverexamples
> > "F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
> > news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> > > Hi All
> > >
> > > I have SQL Data Base . I am using asp application to access this Data
> > Base.
> > >
> > > I want to create a script to generate Data Base on other machines. I
> have
> > > some data in that Data Base, which I required to run my application.
> > >
> > > So the final SCRIPT should contain all relations, default values ,
> > > Identities and Data.
> > >
> > > Which method you advise to achieve these.
> > >
> > >
> > > Kind Regards
> > >
> > >
> > >
> > >
> > >
> >
> >
>|||Try http://www.sqlscripter.com to script your data.
All types are supported: Insert, Update, Delete + Combinations.
It's free.
Thomas
"F@.yy@.Z" wrote:
> Hi All
> I have SQL Data Base . I am using asp application to access this Data Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>

Generating SQL Script

Hi All
I have SQL Data Base . I am using asp application to access this Data Base.
I want to create a script to generate Data Base on other machines. I have
some data in that Data Base, which I required to run my application.
So the final SCRIPT should contain all relations, default values ,
Identities and Data.
Which method you advise to achieve these.
Kind RegardsHere is an article I wrote about generating SQL Server scripts. Hopefully
this will provide you with enough information to help you determine the best
way to generate your script.
http://www.dbazine.com/larsen4.shtml
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> Hi All
> I have SQL Data Base . I am using asp application to access this Data
Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>|||Thanks for your reply.
I tried using enterprise manager but its not creating script for data in the
table, only creating script for table.
Kind Regards
"Gregory A. Larsen" <greg.larsen@.netzero.com> wrote in message
news:ubhT35CaEHA.3888@.TK2MSFTNGP10.phx.gbl...
> Here is an article I wrote about generating SQL Server scripts. Hopefully
> this will provide you with enough information to help you determine the
best
> way to generate your script.
> http://www.dbazine.com/larsen4.shtml
> --
> ----
--
> ----
--
> --
> Need SQL Server Examples check out my website at
> http://www.geocities.com/sqlserverexamples
> "F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
> news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> Base.
have[vbcol=seagreen]
>|||Gregory's article shows you how to generate scripts for objects. One thing
to remember is SQL Server Enterprise Manager or DMO have no capabilities for
scripting the data in the form of INSERT statements.
I wrote a procedure to script data as insert statements, and it can be found
at: http://vyaskn.tripod.com/code.htm#inserts
Alternatively, to move entire database, look up BACKUP/RESTORE and attaching
and detaching databases in SQL Server Books Online.
--
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:%23%23hi0yCaEHA.3112@.tk2msftngp13.phx.gbl...
> Hi All
> I have SQL Data Base . I am using asp application to access this Data
Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>|||Sorry, my methods don't copy the data.
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:Oa6i3HDaEHA.2016@.TK2MSFTNGP09.phx.gbl...
> Thanks for your reply.
> I tried using enterprise manager but its not creating script for data in
the
> table, only creating script for table.
> Kind Regards
>
>
> "Gregory A. Larsen" <greg.larsen@.netzero.com> wrote in message
> news:ubhT35CaEHA.3888@.TK2MSFTNGP10.phx.gbl...
Hopefully[vbcol=seagreen]
> best
> ----
> --
> ----
> --
> have
>|||Check out the free data and schema scripter from Innovartis - the makers of DB Ghost. [
url]www.dbghost.com[/url]
"F@.yy@.Z" wrote:

> Hi All
> I have SQL Data Base . I am using asp application to access this Data Base
.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>|||Try http://www.sqlscripter.com to script your data.
All types are supported: Insert, Update, Delete + Combinations.
It's free.
Thomas
"F@.yy@.Z" wrote:

> Hi All
> I have SQL Data Base . I am using asp application to access this Data Base
.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
>

Wednesday, March 21, 2012

Generating numbers in SQL

hi,

I am developing a ASP.NET application using SQL Server as my database.
I want to create a number that is unique.

The number will have 8 digits.

first 2 digits correspond to year. ex:04 or 03

the next 6 digits start with 000001 and it should get added for each new entry of data.

i am not able to generate number in the way i said. I am relatively new to SQL. so any suggestions as how to go about solving the problem?. Are there any samples/codes available for this.

Any help would be highly appreciated.

thanks,
-sriramWhat are you doing this for? Uniqueness for records in a table? You can use an Identity Column for that...what is the business problem you are trying to solve?|||thanks for your reply.

My client wants to do it in the way i explained before. Is there a way??

-sriram|||You could do it a few ways, the incrementing number being the point of divergence. To get the current month you simply use the Month() function with GetDate()

ex:
SELECT Month(GetDate())

There are a number of ways to build the second part...

One would be to create an identity column and after the insert read the SCOPE_IDENTITY(), combine it with the Month(GetDate()) to get your number. The problem with this is that it relies on work after the insert which could be done through a stored proc or a trigger.

Another approach would be to select the top value from the column, trimming the month prefix and the creating your value by incrementing that number.

Do you need to stuff with zeros? Does the month need to be 1 or 01; does the second number need to be led by zeros?|||hi,

thanks for replying.

The second number needs to be led with zeros.

thanks,

-sriram|||You can use the SQL-Server Function Replicate() for this:


DECLARE @.MaxLength AS int
SET @.MaxLength = 6
DECLARE @.INT AS int

SET @.INT = 1
PRINT REPLICATE('0', @.MaxLength - LEN(LTRIM(STR(@.INT))) ) + LTRIM(STR(@.INT))
-- >> prints 000001

SET @.INT = 1234
PRINT REPLICATE('0', @.MaxLength - LEN(LTRIM(STR(@.INT))) ) + LTRIM(STR(@.INT))
-- >> prints 001234

|||Here is some code that will help; I tried not to use UDFs because I dont know what version of SQL you are using. Regardless this will show you how to parse the old value out and generate a new one.

-- Assumes that the fixed length is 10

Declare @.OldValuechar(10)
Set@.OldValue= '0100000365'

Declare @.OldNumberint
Set@.OldNumber= Cast(Substring(@.OldValue,3, LEN(@.OldValue)-2) as int)

Declare @.MonthNamevarchar(10)
Set@.MonthName= DateName(M, Cast(Left(@.OldValue,2) + '/01/2000' as datetime))

-- Show the old values
select @.OldValue
select@.OldNumber
select @.MonthName

Declare @.MonthPrefixchar(2)
Set@.MonthPrefix= (Select Case WHEN Month(GetDate()) >= 10 THEN Cast(Month(GetDate()) as char(2)) ELSE '0' + Cast(Month(GetDate()) as char(1)) END)

Declare @.NewNumbervarchar(8)
Set@.NewNumber= Cast(@.OldNumber + 1 as varchar)

Declare @.Prefix varchar(7)
Set@.Prefix= ''

While Len(@.Prefix) < (7 - len(@.NewNumber))
Set @.Prefix = '0' + @.Prefix

Declare @.NewValuechar(10)
Set@.NewValue= @.MonthPrefix + @.Prefix + Cast(@.NewNumber as char)

-- Show the New Value
Select @.NewNumber
Select@.NewValue|||thanks,

i think it makes sense.

it should work..

anyway thanks for your reply.

-sriramsql

Friday, March 9, 2012

Generate SQL Script

Hi All
I have SQL Data Base . I am using asp application to access this Data Base.
I want to create a script to generate Data Base on other machines. I have
some data in that Data Base, which I required to run my application.
So the final SCRIPT should contain all relations, default values ,
Identities and Data.
Which method you advise to achieve these.
Kind Regards
What version of SQL Server?
BACKUP and RESTORE
or
sp_detach_db and sp_attach_db
are the easiest methods to move a database
If you truly want to script the database you can use Enterprise Manager or
Query Analyzer to generate the appropriate scripts (to create the tables,
views, stored procedures, and so on). Scripting the data is a bit more
challenging, as you will need to use a tool that will script the data for
you. Some such tools are (in no particular order):
Largo SQL Tools -- http://www.largosqltools.com/
ObjectScripter -- http://www.rac4sql.net/
QALite -- http://www.rac4sql.net/
Lockwood Tech -- http://www.lockwoodtech.com/
Keith
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:uXQYlzCaEHA.3944@.tk2msftngp13.phx.gbl...
> Hi All
> I have SQL Data Base . I am using asp application to access this Data
Base.
> I want to create a script to generate Data Base on other machines. I have
> some data in that Data Base, which I required to run my application.
> So the final SCRIPT should contain all relations, default values ,
> Identities and Data.
> Which method you advise to achieve these.
>
> Kind Regards
>
>
|||I think sp_detach_db and sp_attach_db are best.
Just one more query can I use sp_attach_db in installshield as if I have
..ldf and .mdf files in my pakcge.
Kind Regards
"Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message
news:u0itCKDaEHA.1764@.TK2MSFTNGP10.phx.gbl...[vbcol=seagreen]
> What version of SQL Server?
> BACKUP and RESTORE
> or
> sp_detach_db and sp_attach_db
> are the easiest methods to move a database
> If you truly want to script the database you can use Enterprise Manager or
> Query Analyzer to generate the appropriate scripts (to create the tables,
> views, stored procedures, and so on). Scripting the data is a bit more
> challenging, as you will need to use a tool that will script the data for
> you. Some such tools are (in no particular order):
> Largo SQL Tools -- http://www.largosqltools.com/
> ObjectScripter -- http://www.rac4sql.net/
> QALite -- http://www.rac4sql.net/
> Lockwood Tech -- http://www.lockwoodtech.com/
> --
> Keith
>
> "F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
> news:uXQYlzCaEHA.3944@.tk2msftngp13.phx.gbl...
> Base.
have
>
|||I don't see why not.
Keith
"F@.yy@.Z" <fayyaz.ahmed@.mvwebmaker.com> wrote in message
news:e4VjsvLaEHA.2388@.TK2MSFTNGP09.phx.gbl...[vbcol=seagreen]
> I think sp_detach_db and sp_attach_db are best.
> Just one more query can I use sp_attach_db in installshield as if I have
> .ldf and .mdf files in my pakcge.
>
> Kind Regards
>
>
>
> "Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message
> news:u0itCKDaEHA.1764@.TK2MSFTNGP10.phx.gbl...
or[vbcol=seagreen]
tables,[vbcol=seagreen]
for
> have
>

Sunday, February 26, 2012

generate report using recordset

I am generating crystal reports using recordset in ASP.Now i want to generate the report using reporting services 2000 with the same recordset.how can i do this.pls suggest me.

Thanks

If this is a server report, you need to write a custom data extension as shown here. Alternatively, you can bind the dataset to a local report as explained here.|||

Hi Teo

Thanks for the information...

Here my scenario is different..let me explain you..

First i am generating a recordset object with populated data and putting it into session..

then i am creating an object of crystal report and accessing its database and then its table.

finally filling this table with session data table.here is the code like...

Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")

Set session("oRpt") = session("oApp").OpenReport(path & reportname, 1)

Set session("Database") = session("oRpt").Database

Set session("Tables") = session("Database").Tables

set Session("oTable1") = session("Tables").Item(1)

Session("oTable1").SetPrivateData 3, Session("rstFutureActivity")

where Session("rstFutureActivity") is the recordset object...

Now i want this session object of recordset with Reporting services 2000.

how can i perform this.Pls help me.

|||

Amit,

There is no ReportViewer control for classic ASP (VB6). All incarnations of Reporting Services and their related solutions are .NET based.

|||

Hi Adam,

thanks for reply...

you mean i can't use recordset data to show using reporting services.

Is there any way to make a component in .net which can access recordset data from session object and then pass it to

reporting services for generate the report.

Any suggestion will be appreciable...

thanks

|||

Apologies for not noting that you use classic ASP.You can scratch out the local report option then. A custom data extension is the way to go (see the article link in my first post).

1. You application would serialize the recordset to XML.

2. Pass to your server report as a parameter.

3. CDE will map it to a RS dataset.

The article I mentioned uses an ADO.NET dataset but the implementation approach is essentially the same.

|||How can i map xml data to RS dataset..any more help regarding the same|||Your custom data extension will. Did the article I pointed you to failed to explain this?

Friday, February 24, 2012

generate attributelist from tables

hi there!
I've been working on a project in ASP.NET and SQLserver 2000.
Since this is actually something for school, I must give a report on my work done here.
What I want to do is make an attributelist of all the tables that are in a database, or one at the time would already be a great help!
So for each table I would need in text format all its column names, types en 'allow null' property, but I just can't find out how or with what to do this.

thanks for your help!
Tombaselect * from INFORMATION_SCHEMA.COLUMNS

Sunday, February 19, 2012

generate a xml file from sql server 2000?

hi there.

i'm using asp.net 2 page i'm accessing a table consists of 100 thousands rows and its slow and i'm wondering instead of accessing directly to the table how about if i access via xml ?

generate xml and cache it and use the xml file rather going to sql server database?

has anybody have any help on this?

the steps invloved:

1) first generate a xml file from table something like this:

select * from dbo.LOOK_UP FOR XML AUTO, XMLDATA ?
SELECT * FROM dbo.LOOK_UP FOR XML RAW, ELEMENTS ?
SELECT * FROM dbo.LOOK_UP FOR XML AUTO ?

which one should i use and how do i access after i gnerate a xml file

thanks.

Do you have a PrimaryKey (or clustered index) on that table? Yes, access such a large table in SQL2000 database would be slow, but you can speed up query by using clustered index seek, which I believe should be much quicker than accessing XML file. You can take a look at this link to learn more about clustered index:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_05_5h6b.asp

|||

i do have primary keys and culstered index

but is that true that, if i access xml file it will boost my access speed?

i can cache my xml file and use from cache?

|||

My recomendation is run some test and look for these two System stored procs in the Master database sp_xml_preparedocument and sp_xml_removedocument because you can use them to do a lot of things with XML in SQL Server 2000. The links below show you several options including the Dataset.ReadXml method. Hope this helps.

http://msdn.microsoft.com/msdnmag/issues/05/06/DataPoints/default.aspx

http://forums.asp.net/thread/1024186.aspx

|||

after i run the below code:

DECLARE @.hdoc int
DECLARE @.doc varchar(2000)
SET @.doc = '
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE root
[<!ELEMENT root (Customers)*>
<!ELEMENT Customers EMPTY>
<!ATTLIST Customers CustomerID CDATA #IMPLIED ContactName CDATA #IMPLIED>]>
<root>
<Customers CustomerID="ALFKI" ContactName="Maria Anders"/>
</root>'

EXEC sp_xml_preparedocument @.hdoc OUTPUT, @.doc

what do i do after that?

|||The second page of the thread I gave include a sample using repeater and the ReadXml method of the dataset. Hope this helps.

Generate 2 decimal points?? how?

HI All,

I use MSSQL as my database and ASP.NET as my front application. I want to display Price value S$23.68.

The dayatype I used is smallmoney, but it display: S$23.6800. HOw do I control the number of decimals point in the column of MSSQL??

Thanks a lot

Suigion

Well for monetry values i use datatype Decimal(9,2)

where 9 is the number of digits before Decimal and 2 is the number of digits that u can use after decimal Point

hope that might helps....!!