Should We Use Static Sqlconnection In Aspnet

May 29, 2008

 Should a static connection be used in application. Is it advisable to use a static connection, i mean everytime should i create a new instance of sqlonnection object and then dispose it after use or should i use a static connection
 
plz advise 

View 2 Replies


ADVERTISEMENT

Msg 6573 - Method In Assembly Is Not Static - How Do I Make It Static ?

Feb 22, 2006

I'm using Delphi 2006 to create a DLL which will be integrated into SQL 2005. It's been a long road and I've made a lot of headway, however I am currently having the following problem creating the stored procedure:

My dll name is 'Crystal_Reports_Test_01'
In the DLL, my class is named 'Class01'.
In the DLL, my procedure is named 'TestMe'

I've managed to integrate the DLL into SQL using the following statement:

CREATE ASSEMBLY TEST_ERIC_01
AUTHORIZATION dbo
FROM 'c:mssqlassembliescrystalreports.dll'
WITH PERMISSION_SET = UNSAFE

I am attempting to create the stored procedure which points to the 'TestMe' method inside of the DLL. FYI: 'CrystalReports' is the namespace above my class that I had to add in order to get it to locate the class. The following code is used to create the stored procedure:

create procedure dbo.Crystal_Reports_Test_01(
@Parm1 nvarchar(255)
)
as external name TEST_ERIC_01.[CrystalReports.Class01].TestMe

But I get the following error:

Msg 6573, Level 16, State 1, Procedure Crystal_Reports_Test_01, Line 1Method, property or field 'TestMe' of class 'CrystalReports.Class01' in assembly 'CrystalReports' is not static.

I'm not sure what this means exactly. I think it means the method (the procedure) is not using Static method binding but should be. I have no idea what this really means or how to accomplish this in the DLL - or if I'm even going about this in the right way.

Any help would be appreciated ! I'll post the Delphi code (DLL) below.

Thanks,

Eric Gooden

library CrystalReports;uses System.Reflection, System.Runtime.InteropServices;...................type Class01 = class public procedure TestMe([MarshalAs(UnmanagedType.LPWStr)] var sVarString: wideString); export; end;procedure Class01.TestMe([MarshalAs(UnmanagedType.LPWStr)] var sVarString: wideString); export;begin sVarString:= 'Lets change the value and see if the stored proc. gets the change.';end;end.

View 4 Replies View Related

HT/ASPNET

Jan 25, 2005

Hi
When I am trying to connect to MS Sql Server 2000 through Asp.net using C# , I am getting the error : “ Login Failed for HTASPNET �. Although I have added permission for this account to access the database . I would be very grateful to you if you could kindly explain to me what is the problem. Thank You.

MessageConnection = new SqlConnection("server=HT; Integrated Security = SSPI; Database=Forums");
.
.
MessageConnection.Open();
.
.

View 1 Replies View Related

Can't See ASPNET Account

Mar 24, 2008

I installed SQL Server 2005 and Visual Studio 2005 and have discovered that the ASPNET machine account was not added as a user when going into "Computer Management". I obviously need this to run ASP.net apps.
I tried going to the Administrators group to add user ASPNET, but the system can't find this user.
How can I install the ASPNET account?
 
makimix 

View 3 Replies View Related

ASPNET User

Jun 10, 2004

I just moved my website to a shared host, and I face some trouble.
Since there is more than one DB on the SQL server they don't want to create a ASPNET user. Is there a way to make my SQLCommand use my user name instead of ASPNET ?

Otherwise, can anyone explain to me the result of the ASPNET user on other website who will use the same server as me security wise ?

View 2 Replies View Related

ASPNET Account

Mar 1, 2006

I seem to remember that when using VS2003 to create a website which connected to a MSDE database, I needed to explicitly grant access to the database for ASPNET machine account using the following SQL commands from within a .sql script:
EXEC sp_grantlogin '<machine>ASPNET'EXEC sp_grantdbaccess '<machine>ASPNET'
With VS2005, it sppears that upon creating an .MDF database in the App_Data folder this is no longer necessary.
I'd be interested to know why this is so. Does VS2005 automatically do this when the database is created?
If anybody could shed some light on this I'd be interested.
Thanks,Wayne.

View 2 Replies View Related

How To Return A Static Value?

Apr 25, 2007

I have the following stored procedure...
CREATE Procedure UserGetInfo2 (@UserID int, @SystemTimePeriodID int )As set nocount onSELECT     Users.UserId as UserID, Users.UserName as UserName, Users.RealName as RealName, UserTimePeriod.BudgetCode as BudgetCode, UserTimePeriod.SystemTimePeriodID as SystemTimePeriodID, Users.Password as Password, Users.SSN as SSN, Users.Location as Location, Users.ScheduleType as ScheduleType, Users.EmployeeType as EmployeeType, Users.TimeAccounted as TimeAccountedFROM      Users INNER JOIN UserTimePeriod ON Users.UserId = UserTimePeriod.UserIDWHERE     (users.userID= @UserID) AND (UserTimePeriod.SystemTimePeriodID = @SystemTimePeriodID)returnGO
The problem lies in that when a person has a SystemTimePeriodID over a certain value, there is no UserTimePeriod record since it has not been created yet.
Obviously, I need to wrap this in an IF...EXISTS
IF EXISTS (SELECT UserTimePeriodID FROM UserTimePeriod WHERE (SystemTimePeriodID = @SystemTimePeriodID) AND (UserID = @UserID)) 
(the SELECT above, since that's what needs to come back if the data exists) 
ELSE
Do the same select but put in a static value for BudgetCode, like '0000' 
GO
How could I do the part where the IF...EXISTS fails?
I'm... not sure I can use RETURNS, since it feeds into this recordset:
rstUserInfo2.Open "UserGetInfo2 " & Request("UserID") & ", " & Request("SYSTIMEPERIODID") 
and later uses values from that RecordSet, such as <td><%=rstUserInfo("BudgetCode") & ""%></td>  
 

View 4 Replies View Related

What Is The Best Way Yo Add A Static Value Column?

May 30, 2008

Hello,

I have a OLE DB on a Data Flow that execute a query and returns 5 columns i want to add a new column with a static value that a have on a Variable.

I use Derived Column in order to create the new column adding the variable value in the expression field, Is this the best way??

Thanks

View 4 Replies View Related

Getting Is Not Static When Trying To Deploy

Nov 10, 2006

I'm attemping to deploy a crypto class that we use on a desktop app to SQL Server. I'll use the encryptstring/decryptstring found in this class as User Defined Functions on SQL Server. When I try to deploy the class I'm getting this error:



Error 1 Method, property or field 'EncryptString' of class 'EncryptingDecryptingOASISPWDS.Crypto' in assembly 'EncryptingDecryptingOASISPWDS' is not static. EncryptingDecryptingOASISPWDS




Here is the code:



Imports System

Imports System.Data

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Imports Microsoft.SqlServer.Server

Imports System.Security.Cryptography

Imports System.Text 'for UnicodeEncoding

Imports System.IO 'for MemoryStream, FileStream, Stream, Path

Imports System.Threading 'for Thread.Sleep

Partial Public Class Crypto

'Private Const CodeVersion As String = "01.00.00"

'class member variables

Private m_sPassPhrase As String

'class private variables

Private mbytKey() As Byte 'crypto key

Private mbytIV() As Byte 'Initialization Vector

Private mbKeyIsSet As Boolean = False

Private mksKeyNotSetException As String = "Crypto passphrase is not set."

Private mksPassphraseTooSmall As String = "PassPhrase length must be at least {0} characters."

'--- class constructors

Public Sub New()

'no passphrase is useful for GetHashString/ValidPassword methods

End Sub

Public Sub New(ByVal CryptoPassPhrase As String)

PassPhrase = CryptoPassPhrase

End Sub

'--- class public properties

'generate and store encryption key & iv from passphrase

Public Property PassPhrase() As String

Get

Return m_sPassPhrase

End Get

Set(ByVal Value As String)

Const iMinLength As Integer = -1 '-1 disables min length

m_sPassPhrase = Value.Trim

'enforce a rule on minimum length if desired here

If (Value.Length > iMinLength) Or (iMinLength = -1) Then

Dim sha2 As New SHA256Managed()

'256 bits = 32 byte key

mbytKey = sha2.ComputeHash(BytesFromString(m_sPassPhrase))

'convert to Base64 for Initialization Vector, take last 16 chars

Dim sKey As String = Convert.ToBase64String(mbytKey)

mbytIV = Encoding.ASCII.GetBytes(sKey.Remove(0, sKey.Length - 16))

mbKeyIsSet = True

sha2 = Nothing

Else

mbKeyIsSet = False

Throw New Exception(String.Format(mksPassphraseTooSmall, (iMinLength + 1).ToString))

End If

End Set

End Property



'decrypt a stream

Public Function DecryptStream(ByVal EncryptedStream As MemoryStream) As MemoryStream

If mbKeyIsSet Then

Try

'create Crypto Service Provider, set key, transform and crypto stream

Dim oCSP As New RijndaelManaged()

oCSP.Key = mbytKey

oCSP.IV = mbytIV

Dim ct As ICryptoTransform = oCSP.CreateDecryptor()

Dim cs As CryptoStream = New CryptoStream(EncryptedStream, ct, CryptoStreamMode.Read)

'get bytes from encrypted stream

Dim byteArray(EncryptedStream.Length - 1) As Byte

Dim iBytesIn As Integer = cs.Read(byteArray, 0, EncryptedStream.Length)

cs.Close()

'create and write the decrypted output stream

Dim plainStream As New MemoryStream()

plainStream.Write(byteArray, 0, iBytesIn)

Return plainStream

Catch ex As Exception

Return Stream.Null

End Try

Else

Throw New Exception(mksKeyNotSetException)

End If

End Function

'decrypt a string - wrapper without Base64 flag (True by default)

Public Function DecryptString(ByVal EncryptedString As String) As String

Return _DecryptString(EncryptedString, True)

End Function

'decrypt a string - wrapper with Base64 flag

Public Function DecryptString(ByVal EncryptedString As String, ByVal Base64 As Boolean) As String

Return _DecryptString(EncryptedString, Base64)

End Function





'encrypt a stream

Public Function EncryptStream(ByVal PlainStream As MemoryStream) As MemoryStream

Try

'open stream for encrypted data

Dim encStream As New MemoryStream()

'create Crypto Service Provider, set key, transform and crypto stream

Dim oCSP As New RijndaelManaged()

oCSP.Key = mbytKey

oCSP.IV = mbytIV

Dim ct As ICryptoTransform = oCSP.CreateEncryptor()

Dim cs As CryptoStream = New CryptoStream(encStream, ct, CryptoStreamMode.Write)

'get input stream into byte array

Dim byteArray() As Byte = PlainStream.ToArray()

'write input bytes to crypto stream and close up

cs.Write(byteArray, 0, PlainStream.Length)

cs.FlushFinalBlock()

cs.Close()

Return encStream

Catch ex As Exception

Return Stream.Null

End Try

End Function

'encrypt a string - wrapper without Base64 flag (True by default)

<Microsoft.SqlServer.Server.SqlFunction()> _

Function EncryptString(ByVal PlainText As String) As String

Return _EncryptString(PlainText, True)

End Function

''encrypt a string - wrapper with Base64 flag

<Microsoft.SqlServer.Server.SqlFunction()> _

Public Function EncryptString2(ByVal PlainText As String, ByVal Base64 As Boolean) As String

Return _EncryptString(PlainText, Base64)

End Function

'calculates the hash of InputValue, returns a string

'- SHA1 hash is always 20 bytes (160 bits)

Public Function GetHashString(ByVal InputValue As String) As String

Try

Dim inputBytes() As Byte = BytesFromString(InputValue)

Dim hashValue() As Byte = New SHA1Managed().ComputeHash(inputBytes)

Return BytesToHexString(hashValue)

Catch ex As Exception

Return String.Empty

End Try

End Function

'returns True if hash of Passphrase matches HashValue

Public Function ValidPassword(ByVal Passphrase As String, ByVal HashValue As String) As Boolean

Return (GetHashString(Passphrase) = HashValue)

End Function





'internal string decryption

Private Function _DecryptString(ByVal EncryptedString As String, ByVal Base64 As Boolean) As String

Try

'put string in byte array depending on Base64 flag

Dim byteArray() As Byte

If Base64 Then

byteArray = Convert.FromBase64String(EncryptedString)

Else

byteArray = BytesFromString(EncryptedString)

End If

'create the streams, decrypt and return a string

Dim msEnc As New MemoryStream(byteArray)

Dim msPlain As MemoryStream = DecryptStream(msEnc)

Return BytesToString(msPlain.GetBuffer)

Catch ex As Exception

Return String.Empty

End Try

End Function



'internal string encryption

Private Function _EncryptString(ByVal PlainText As String, ByVal Base64 As Boolean) As String

Try

'put string in byte array

Dim byteArray() As Byte = BytesFromString(PlainText)

'create streams and encrypt

Dim msPlain As New MemoryStream(byteArray)

Dim msEnc As MemoryStream = EncryptStream(msPlain)

'return string depending on Base64 flag

If Base64 Then

Return Convert.ToBase64String(msEnc.ToArray)

Else

Return BytesToString(msEnc.ToArray)

End If

Catch ex As Exception

Return String.Empty

End Try

End Function

'returns a Unicode byte array from a string

Private Function BytesFromString(ByVal StringValue As String) As Byte()

Return (New UnicodeEncoding()).GetBytes(StringValue)

End Function

'returns a hex string from a byte array

Private Function BytesToHexString(ByVal byteArray() As Byte) As String

Dim sb As New StringBuilder(40)

Dim bValue As Byte

For Each bValue In byteArray

sb.AppendFormat(bValue.ToString("x2").ToUpper)

Next

Return sb.ToString

End Function

'returns a Unicode string from a byte array

Private Function BytesToString(ByVal byteArray() As Byte) As String

Return (New UnicodeEncoding()).GetString(byteArray)

End Function





'Return True when the file is available for writing

'- returns False if output file locked, for example

Private Function CheckWriteAccess(ByVal FileName As String) As Boolean

'2 second delay with 10,200

Dim iCount As Integer = 0 'retry count

Const iLimit As Integer = 10 'retries

Const iDelay As Integer = 200 'msec

While (iCount < iLimit)

Try

Dim fs As FileStream

fs = New FileStream(FileName, FileMode.Append, _

FileAccess.Write, FileShare.None)

fs.Close()

Return True

Catch ex As Exception

Thread.Sleep(iDelay)

Finally

iCount += 1

End Try

End While

Return False

End Function

End Class

View 4 Replies View Related

DB Copy ASPNET Acc. Problem

Jul 25, 2006

Hi,
I've recently copied an SQL DB (detach, copy data files, reattach) from SQL-Express on one machine to SQL 2005 on a new host.  However I cannot set the permissions correctly for the ASPNET account.
It's current permissions use <oldhost>ASPNET which persists even if I remove it and reload the DB.  I need to allow the access for the new host machine's ASPNET account but it cannot be found :/
Any advice anyone can offer would be greatly appreciated!
Regards,
Doug

View 1 Replies View Related

ASPNET Security On My Sql Server

Aug 31, 2006

Dear allI had a problem connecting to my website (through lan) from other machines in the company here.I googled some and figured out that I have to change the security settings of aspnet in my sql server express 2005.I did as suggested and now its workingMy question is - what should be the real security settings for aspnet on my sql server ?Should I really add it to the sysadmin ? (what solved the problem....) Guy 

View 3 Replies View Related

How Do I Add ASPNET User To SQLExpress DB?

Sep 1, 2006

I am going though the ASP.NET QuickStart tutorials.  One of the lessons is to add a datagrid.  I am able to do that with VWD and am able to connect to the database in VWD.  However when I try to execute the application I get a "Login failure" message because the user pcName/ASPNET cannot login. How do I add the ASPNET user to the SQLExpress database?  There don't seem to be any administration tools that were installed with SQL Server Express 2005. Thanks in advance for the help!

View 3 Replies View Related

How To Add Aspnet User To Sqlexpress

Apr 15, 2007

Hi guys
 
I am trying to add aspnet user to sqlexpress. I am able to select the asp.net however when I click on OK button,
it is asking me to enter a name for it. COuld you tell me what name I should enter? I tried computernameaspnet didn't help?
 is there better way to do this?
 thanks for your help
Cemal

View 1 Replies View Related

Who Is Connected : Aspnet Or Iusr_

Apr 18, 2007

Hi

I spent the whole week trying to find a solution with a problem of authorization/access on a new website (aspnet2 + slqserver 2005)

The site was running well in the test environnement but once deployed the production site behavior was quite erractic. some clients run ok, others not and that changes for the same client with each session.

it appeared that the problem came from the access to stored procedures. sometime, theirs accesses were authorized sometime denied.

finally, tests showed that the client's userid was either aspnet or iusr_

by putting the same permissions on these 2 accounts, the problem is solved and all the clients are running fine.

now the question : for which reason the client connect randomly to one or the other of these 2 id ? is this normal ?

best regards

View 1 Replies View Related

How To Include ASPNET.MDF In My Database?

Jan 25, 2008

Hi,
I have a test database and need to to include the aspnet.mdf into my database.
I have generated a script for the aspnet.mdf, but don't know how to run/include this into my own test database.
1. Is there any magical sql-command that do the job in a clean way for me?
2. How can I change the name of aspnet in that auto generated script, if needed at all?
I have: SQL server Express Edition 2005, Visual Web Developer Express Edition 2008
 
Thank's
/Pepe

View 1 Replies View Related

Question About Aspnet Membership Db

Mar 15, 2008

I know this may sound like a silly question but, my project currently uses two databases, the aspnet membership db and our application db. What I'm wanting to know is if there is a way to combine them without lossing any current functionality from either one? Also what if any gotchas there might be?

View 5 Replies View Related

Tweaking The ASPNET Tables..

May 7, 2008

Hello everyone! Following are the things that I have to do :1) Create a "Friendlist" of every user registered.  ( one user can have many friends)2) Create "Communities" which can have various users registered to them. How do I go about doing this in ASP.net..?! Please help!  

View 10 Replies View Related

Could Not Add ASPNET User To SQL Server.

Dec 1, 2003

10:15:50 PM Monday, December 01, 2003: [Fail] Could not add ASPNET user to SQL Server.
SQL Server does not exist or access denied.

hey guys can someone help me out on this or point me to another forum with the same problem and the answer this problem thank you

View 10 Replies View Related

User In SQL Server Is ASPNET?

Jun 15, 2004

I have developed an asp.net application and have deployed it to the web server. The application accesses an SQL Server to allow users to make changes to data. My connection string is the following:

"data source=" & ServerName & ";initial catalog=" & DatabaseName & ";integrated security=SSPI;" & "persist security info=False;packet size=4096"

On the SQL Server side, I have a trigger that logs when changes are made and by whom. The suser_sname returns <Servername>ASPNET as the user making the change. Why is this? Should it not be the user id of the user? If the SQL Server thinks that the current user is ASPNET then how can it make changes when this is not a user defined for the database.

The web site is set up to allow for Integrated Windows Authentication only. SQL Server is on the same machine as the web server.

View 2 Replies View Related

Grant ASPNET All Access

Feb 10, 2005

hello all,

I would like to grant the MACHINENAMEASPNET user all acccess to my MSSQL database (i.e tables and stored procedures. I can do this through enterprise manager but id rather do it programatically so i can add it to my database creation script. What is the syntax for this?

I thought it would be along the lines of:

Grant all on databasename to localhostASPNET.

But obviously its not! Please help!

thanks

Tom

View 1 Replies View Related

ASPNET User In MSDE

Feb 18, 2005

Hello.

I am using MSDE in an ASP .NET application using forms authentication in order to the user can visit my website anonymously but have to authenticate in some pages.

Web server and MSDE server are in the same computer.

I would like to know how role I should set for the ASPNET sql server user. I am using Microsoft SQL Web Data Administrator and when I am creating the ASPNET user, then a page with some roles is shown.

Roles like public (default), db_owner, db_accessadmin, db_datareader, db_datawriter...

I had applied db_datareader and db_datawriter but now, when I use store procedures in my code, an error is made so I have applied db_owner role for the ASPNET user.

Is this correct or db_owner is a excessive privileged role for the ASPNET user?

Thank you and sorry for my English.

View 1 Replies View Related

How To Add ASPNET Account To Your Database

Mar 31, 2005

This is the error message "Login failed for user 'SUSHMAASPNET'. "
I am Building a Data Form that displays data from a single table- the Customers table in the Northwind sample Database.
I have Visual Studio.Net 1.0 and SQL Server 2000.
So I feel that I need to add an ASPNET account to my database.
Please could someone tell me if this could solve the problem, if so
please could you tell me how to Add an ASPNET account to my database?
Thank you

View 2 Replies View Related

HowTo Add ASPNET User?

Jul 6, 2005

The objective is to configure on a dev machine. Selecting New Database User is the easy part as the ***ASPNET user can be selected from the drop down listbox. What follows and what to do next is a myriad of choices. What needs to be done next? Is there a step-by-step document somewhere that you can refer?

View 1 Replies View Related

Stop Using &<machinename&>aspnet With SQL

May 2, 2007

I'm working on a big project, and in about 3-4 months I'm looking to put out out as a web app for some local businesses. My question is, is there a way I can disable having to use a <machinename>aspnet, and just use a SQL user I create? Otherwise, I'm not sure how I'm going to give the <machinename>aspnet access to my database in case I add more tables and what not.

Not sure if this should go here or in the SQL thread. Thanks

View 4 Replies View Related

Calling Sp_helptext From ASPNET

Jul 23, 2005

Hi,I am executing a call to "sp_helptext" from a web service, in order toobtain the text of a stored procedure. The call itself seems to be ok buteventually it throws an exception saying that the specified object does notexist in the database - which is a false statement, i've checked carefully.I probably do not have enough rights to access something from the ASPNETaccount.Do i have to login as "sa"? Is this the only solution available?Bogdan.

View 1 Replies View Related

Using A Static Class As Sql Layer ?

Jun 12, 2008

Can I use this class in ASP.NET web site with many visitors?SqlLayer.cs: public static class SqlLayer{ public static string ConnectionString = ConfigurationManager.ConnectionStrings["SomeConnectionString"].ConnectionString; public static int ExecuteNonQuery(string StoredProcedureName, string[] ParamNames, object[] ParamValues) { if (ParamNames.Length != ParamValues.Length) { throw new Exception("ParamNames.Length != ParamValues.Length"); } using (SqlConnection cSqlConnection = new SqlConnection(ConnectionString) { cSqlConnection.Open(); SqlCommand cSqlCommand = cSqlConnection.CreateCommand(); cSqlCommand.CommandType = CommandType.StoredProcedure; cSqlCommand.CommandText = StoredProcedureName; cSqlCommand.Parameters.Add("@ReturnValue", DbType.Int32); cSqlCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.ReturnValue; for (int i = 0; i < ParamValues.Length; i++) { cSqlCommand.Parameters.AddWithValue(ParamNames[i], ParamValues[i]); } cSqlCommand.ExecuteNonQuery(); return (int) cSqlCommand.Parameters["@ReturnValue"].Value; } } public delegate void ActionForReader(SqlDataReader Reader); public static void ExecuteReader(string StoredProcedureName, string[] ParamNames, object[] ParamValues, ActionForReader cActionForReader) { using (SqlConnection SqlConnection1 = new SqlConnection(ConnectionString)) { SqlConnection1.Open(); SqlCommand SqlCommand1 = SqlConnection1.CreateCommand(); SqlCommand1.CommandType = CommandType.StoredProcedure; SqlCommand1.CommandText = StoredProcedureName; for (int i = 0; i < ParamValues.Length; i++) { SqlCommand1.Parameters.AddWithValue(ParamNames[i], (ParamValues[i] == null ? DBNull.Value : ParamValues[i])); } using (SqlDataReader Reader = SqlCommand1.ExecuteReader()) { if (cActionForReader != null) { //if (Reader.HasRows == false) throw new Exception("Reader has no rows"); //if (Reader.RecordsAffected == 0) throw new Exception("Reader RecordsAffected = 0"); while (Reader.Read()) { if(Reader!=null) cActionForReader(Reader); } } } } }}   Using: SqlLayer.ExecuteNonQuery("SomeStoredProcedure", "ID", ID);---------SqlLayer.ExecuteReader("SomeStoredProcedure", new string[]{"Param1","Param2"}, new object[]{Value1,Value2}, Action);...void ActionForForumCollection(SqlDataReader Reader) {LabelContent.Text += Reader[0].ToString()+" - "+Reader[1].ToString();}  

View 1 Replies View Related

Select 'static' Row/result

Oct 17, 2006

Let's say I have a simple query to return the results of my "Status" table. The query reads as follows:


Code:


Select statusID, statusName
From Status



Here is the result set that I am returned:


Code:


22 Associate Member
23 Is Not Paying
24 Exempt
25 Fair Share
26 Member
29 Retiree
30 Staff
32 Fair Share - Self Pay
34 Member - Self Pay



Now, I am using this query for reporting purposes and would like to inject some additional sql that will append one additional row to my result set -- this is what I am calling the 'static' row in the thread title.

In other words, without modifying my database I would like to return the above set of data but with one additional row that has an arbitrary ID with the name "Unknown" or something similar.

again, I want to avoid adding an "Unknown" field directly to my database -- is their any way to "hard code" the selection of this row in my sequal?

Thanks,

Zoop

View 1 Replies View Related

Virtual To Static Table

May 26, 2004

:confused: Please forgive this elementary question. I have database which has a view that produces the desired records and fields from multiple tables. As I understand it a view is a Virtual Table. My problem is I need to export these results periodically to deliver to a customer. I am running this database on SQL Server 2000 if I right click on a table I have the option to dts the data to a text file but when I right click on the view I do not have this option. How can I make this virtual table an actual table. PLEASE Help Thank You, Ed

View 1 Replies View Related

Static And Dynamic Tables

Sep 26, 2006

dear experts,

i heard in a session, that the tables which are modifying continuously are known as dynamic tables.and which are not are known as static tables.

my question is how to find the statics to judge static and dynamic tables?

View 4 Replies View Related

Declare Un-static Decimal Value

Oct 12, 2007

I try to declare a variable with un static decimal point in the following statement:-

declare @mpt int;
declare @mpq nvarchar (1)
SELECT @mpq = (SELECT mpq FROM ims.parm)

exec('declare @MM1 decimal (10,'+ @mpq +');')

set @mm1 = 1
print @mpt
when i print the declare statement looks like the following:
declare @MM1 decimal (10,2);
but with exec the statement, I have the following error:-
Msg 137, Level 15, State 1, Line 18
Must declare the scalar variable "@mm1".

Best regards

View 2 Replies View Related

Procedure/static Cursor

Mar 30, 2008

can someone tell me how to use static cursor to read the rows applying it in procedure.
i have input and output tables
i will have to use input table to read data and then in procedure update/insert into output table ) insert values from input and dditioanl calulate charges.
ok, there is my problem:
An Internet service provider has three different subscription
packages for its customers:

Package A: For $15 per month with 50 hours of access provided.
Additional hours are $2.00 per hour over 50 hours.
Assume usage is recorded in one-hour increments,
i.e., a 25-minute session is recorded as one hour.

Package B: For $20 per month with 100 hours of access provided.
Additional hours are $1.50 per hour over 100 hours.


Package C: For $25 per month with 150 hours access is provided.
Additional hours are $1.00 per hour over 150 hours

Assume a 30-day billing cycle.

1) Create a table to hold customer input billing data.

2) Populate input table with follwing records:

CustomerID Pkg Hours
---------- --- ------
1000 A 49
1010 A 50
1020 a 90
1030 a 130

1090 B 40
1100 B 99
1110 b 100
1120 b 145

1140 C 45
1150 c 85
1160 c 149
1170 c 150
1180 c 200


3) Create a table to hold customer data used to generate
the statement to be sent to the customer. It should
include CustomerID, Package, HoursUsed, and Charges.

Write an SQL script that reads customer billing data,
calculates a customer’s monthly charges, and populates
the customer statement table.
Use Cursor to process records and Stored Procedures for
ProcessBill and calcCharges.


CREATE TABLE custinput(
cust_id int NULL,
pkg char(1) NULL,
hrs smallint NULL
)

CREATE TABLE custoutput(
cust_id int NULL,
pkg char(1) NULL,
hrsused smallint NULL,
charges money null

)




insert into custinput values (1000,'A',49);
insert into custinput values (1010,'A',50);
insert into custinput values (1020,'a',90);
insert into custinput values (1030,'a',130);
insert into custinput values (1090,'B',40);
insert into custinput values (1100,'B',99);
insert into custinput values (1110,'b',100);
insert into custinput values (1120,'b',145);

insert into custinput values (1140,'C',45);
insert into custinput values (1150,'c',85);

insert into custinput values (1160,'c',149);
insert into custinput values (1170,'c',150);
insert into custinput values (1180,'c',200);

then there is conditions:

if upper (@pkg)= 'A'
begin
if @hrs<= 50 set @charges =15
else set @charges =15 + (@hrs-50)*2

end;

else if upper(@pkg)= 'B'
begin
if @hrs <= 100 set @charges = 20
else set @charges = 20 + (@hrs - 100)*1.5

end;
else

if @hrs <=150 set @charges = 25
else set @charges =25+(@hrs-150)

insert into custoutput values(@cust_id,@pkg,@hrs,@charges)

View 3 Replies View Related

What You Mean By Static Group In Matrix?

Jul 21, 2007

What you mean by static group in matrix?

View 2 Replies View Related

Deleting A Static Matrix Row

Jul 30, 2007

This seems like it should be extremely obvious. I don't know if I'm just going insane or what...

If I add a matrix to my report and then right click a "data cell", I can add columns and rows. I go ahead and add however many columns and rows I want. Now I want to delete one of the rows I just added, how do I do that?

I have tried highling the entire row, but it doesn't allow me to delete it. If I select just one cell and click delete, it deletes the column and not the row. I can just use the "undo" command right after I create it, but if I have already done numerous other things to the report, it removes all of that first.

I must be missing something very obvious here.

View 19 Replies View Related







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