.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Function and Variable declaration with out an 'As' clause

Posted By:      Posted Date: August 25, 2010    Points: 0   Category :ASP.Net

I get a message - "Function without an 'As' clause" for HMAC_MD5 and "Variable declaration without an 'As' clause" for Key and Value.  But the code works.  But the messages still exists.  Is there a way to fix this to avoid the messages?

Function HMAC_MD5(ByVal Key, ByVal Value)


View Complete Post

More Related Resource Links

BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its


why do i get

BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

with the code

 below ..thanks


<form id="form1" runat="server">
               <asp:Button ID="Button1" runat="server" Text="Run Access" />
In your code behind:

Initializing more than one variable at declaration


Guys, i am looking for this using google search but without success yet...

How can I do this:

private string a, b, c, d ,e = "";

I want ALL the variables to start with "" but this is not what i get...  so i am doing this until the answer does not come:

private string a,b,c,d,e;

a = b = c = d = e = "";



Declaration of a Variable in a webform

Hi All, Please review my code, i've removed the most part of the code which is not relevant to this: namespace MyQuiz { public partial class QuizPage : System.Web.UI.Page { protected int[] idquestion = new int[totalQuestions]; public QuizPage() { Page.Init += new System.EventHandler(Page_Init); } private void ReadQuestionsIntoTable() { IEnumerable questions = SelectRows("Select * From Questions WHERE QuizID='48'"); //Ashiq Code int a = 0; foreach (DataRowView question in questions) { a++; } totalQuestions = a; foreach (DataRowView question in questions) { idquestion = new int[totalQuestions]; idquestion[NumberOfQuestions] = Convert.ToInt16(question["QuestionID"].ToString()); } } protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { ReadQuestionsIntoTable(); } else { bool AreAllAnswered = CalculateScore(r);

SSRS 2005 SP3 - Instr function with Global Variable fails in Subscriptions

Hi I have a very simple expression in a text box in my report:  INSTR(Globals!ReportServerUrl,"Report").  This expression should return the integer value of where the string "Report" appears in the Global variable for the ReportServerUrl.  Simple enough.  This works fine for generating the report directly through report manager, and in my case returns a value of 20. However when run as a subscription and emailed to myself the value returned is 0. This suggests that the search string does not appear in the Global variable. In the reportserver config file the URLroot tag contains the correct server address - http://myserver/reportserver. Does anyone know why i should be experiencing this issue with my subscriptions?  Your help would be much appreciated! Thanks Guy  Guy

Scalar Function Variable length return value

Would like to write a Scalar Function that returns a variable length string of spaces. Length being determined by an input parameter (int) Maybe I am missing the obvious but it seems impossible because you have to declare the size  of the varchar return variable I know there is a performance hit using scalar functions but we are generating a view that emulates an old fixed file format with lots of unused fields. So it will make the resultant view readable. So I am looking to do select goodfield1,fnSpace(5) as Unusedfield1,goodfield2,fnSpace(10)... from MyView thanks Bob

Pipe SQL Query function into Variable with no column headings

Hello, I don't know if I'm in the right forum but could not find one for Powershell. I need to return 1 piece of data from a sql database to a variable. I don't want the column headings. Here's what I have so far:         Function GetMenuGroup ([int]$StoreID) { $SqlConnection = New-Object System.Data.SqlClient.SqlConnection $SqlConnection.ConnectionString = "Server=Servername;Database=DatabaseName;Integrated Security=True" $SqlCmd = New-Object System.Data.SqlClient.SqlCommand $SqlCmd.CommandText = "exec storedProcedure $StoreID" $SqlCmd.Connection = $SqlConnection $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter $SqlAdapter.SelectCommand = $SqlCmd $DataSet = New-Object System.Data.DataSet $SqlAdapter.Fill($DataSet)|out-null $SqlConnection.Close() $DataSet.Tables[0] } $MG=Getdata 2 |out-string Here's the results I get now - How do I return just "DatathatIreallyWant" in a string variable? I don't want the column or underline. ColumnName ------------- DataThatIreallyWant   Thank you, MG2

Use of PATINDEX function in select clause With Linq

hello       i have an problem to use of PATINDEX function in select clause with Linq.      if anyone have any clue about it then please update me its urgent.Thanks In Advance.

a function in the where clause?

I have this where clause that I use in so many different places, I wanted to see if it is possible to have it as a function or something so that in the case I have to ever change it, I won't have to go through 50+ queries to change it.   Select * From Table1 Where IsTableAvailable = 1 AND (IsTableBroken = 0 OR IsTableFixed = 1)    

Order By clause in RowNumber function slowing down the performance of my query.



I have a query which has a paging functionality and for which i'm using ROW_NUMBER() function. The order by clause in my rownumber function is dynamic and gets changed all the time when ever the sp is called. It works fine for few columns but for one column which is of datetime datatype, it takes lot of time. Amazing thing is with when i sort by the same column in descending order, the query runs in a sec but ascending order takes lot of time :(.

I tried creating a non clustered index(as i already i have a clustered index on that table) on that datetime column but it did not help me.

Could you please suggest what i can do to improve the performance.






using table name variable in create function


anybody help me, i wanna create function using table name parameter.

this is my function code

ALTER function [dbo].[CreateRecID]( @TableName varchar(100))
returns bigInt
declare @RecID bigint
declare @Sql varchar(2000)
set @Sql = (select case when max(RecID) is null then 0 else max(RecID) + 1 end as RecID from @TableName)

return @Sql

when i run this code

i got error "Must declare the table variable "@TableName".

I have already declare a @TableName Parameter.

can you show me the way to solve my problem?

Thanks so much

SQL MAX() function selecting ALL columns and not only those in the GROUP BY clause


A school has classes. Each class has students. Each student may take up one or several courses.

One only table with thousands of rows contains the following columns (and some others):

  1. Student´s class
  2. Student id-number
  3. Student's course
  4. Student's grade (in the course)
  5. Some other rows. This table has about 25 rows

I need an only SELECT that brings ALL ROWS for each student's highest grade (grades are numbers, not letters).

In the example bellow, I have listed a fragment of the table and I have emphasized with bold and italic characters the rows that are supposed to be selected:

          Class       ID-number     Course     Grade     Row5   Row6   Row7... 

  1. Class-A         100001     Math&n

max() agreate function and having clause not working as expected


I wil try to describe below my issue, starting with the query i use.

SELECT     b.[id_training_MD],
FROM [training_MasterData] as a
inner join [training_Log] as b
    on a.id_training_MD = b.id_training_MD
inner join [training_Q_Log] as c
    on b.id_training_Q_Log = c.id_training_Q_Log
WHERE (a.[Category] = 'Networking')  and  (c.[employeeID] = '123')

group by b.[id_training_Q_Log],b.[id_training_MD],b.[trainingScore]   
having b.[id_training_Q_Log] = (select distinct max(b.[id_training_Q_Log]) FROM [training_Log])

My tables are:

CREATE TABLE [dbo].[Training_MasterData](
    [id_Training_MD] [int] IDENTITY(1,1) NOT NULL,
    [Category] [varchar](50) NOT NULL,
    [TrainingName] [varchar](100) NOT NULL

Example of data from table:
[id_Training_MD]    [Category]         [TrainingName]

Passing variable into function in SQL Server from Access



I am trying to call a function in SQL Server 2005 from Access 2003.  It works fine with the constant value, but fails with a variable of the same value.  This works:

strSQL = "SELECT * FROM functionName (constantValue)"
rs.Open strSQL, cn 

But when I use variable in the parameter, I get error.  I have tried creating parameter objects in Access, but couldn't execute it and don't know if this is a way to go anyway.

Would appreciate for any help or suggestion.


Thank you

can i create a Clr ud Aggregate Function with over/ order by clause?


i want create a UD Aggregate like  Row_Number () for using with 'Over (Order By ...) ' (not like sum() over (part....)

is it possible?

Can I Feed a table variable or table-like types to my function(My SQL version 2005 Standard SP3)?


Hello All:


My question is whether I can feed a table variable to my table-valued function in SQL 2005 SP3 standard edition?

If no, can I feed a XML type to the function? I guess, probably I can feed a XML. Yet, for this case I am afraid , in the function, the XML-parsing may be costly if I stuff over 10K uniqueIdentifier data into this XML variable.

Any good idea from you ?



--Derek D. 


Global variable declaration



I am using the following code:

    var dbSelect = Database.Open("XXXXXX") ;
    var selectQueryString = "SELECT * FROM XXXX ;
    var data = dbSelect.Query(selectQueryString);
Now If I put the above code in try catch block, then "data" variable is not accessible outside try block. How I can declare "data" variable globally and then can collect result in it in try block?

Sql 2008 Variable declaration


Wondering can we do like below.


SELECT @iSalary = Salary

FROM dbo.udf_Get_Salary(EMP0001)


Instead of doing old conventional way




SELECT @iSalary = Salary

FROM dbo.udf_Get_Salary(EMP0001)


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend