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

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

Problem with class files

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net

using vs2010

I created an empty web site project and I'd like to use my own DAL to interact with a SQL Database. 

My class file looks like the following:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace BatiksGalore
  public class Calendar
  public SqlDataReader GetEventsByDate (string date)


I don't know why but the IDE won't let me construct methods this way. There's a squiggly line under 'SqlDataReader' and the error is 'Expected class, delegate, enum, struct, ...etc.'

I've done this before on Web Site projects and it works fine. Normally intellisense allows me to choose 'SqlDataReader' but in this project (which I've never used before, BTW) I don't have the option.

Any help is appreciated.

View Complete Post

More Related Resource Links

Zip Your Data: Using the Zip Classes in the J# Class Libraries to Compress Files and Data with C#


Zip compression lets you save space and network bandwidth when storing files or sending them over the wire. In addition, you don't lose the directory structure of folders you Zip, which makes it a pretty useful compression scheme. The C# language doesn't have any classes that let you manipulate Zip files, but since .NET-targeted languages can share class implementations, and J# exposes classes in the java.util.zip namespace, you can get to those classes in your C# code. This article explains how to use the Microsoft J# class libraries to create an application in C# that compresses and decompresses Zip files. It also shows other unique parts of the J# runtime you can use from any .NET-compliant language to save some coding.

Ianier Munoz

MSDN Magazine June 2003

Problem with Scripter class in powershell

tweaked my wits on this one. can't figure it out!i'm trying to follow the steps at the bottom of this page http://www.mssqltips.com/tip.asp?tip=1842  [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO')| out-null # Create an SMO connection to the instance$s = new-object ('Microsoft.SqlServer.Management.Smo.Server') "LOCALHOST\SQL2005_1" $dbs = $s.Databases$dbs["Northwind"].Script() | Out-File D:\PSScripts\NWind.SQL $scrp = new-object ('Microsoft.SqlServer.Management.Smo.Scripter') ($s) $scrp.Options.AppendToFile = $True$scrp.Options.ClusteredIndexes = $True$scrp.Options.DriAll = $True$scrp.Options.ScriptDrops = $True$scrp.Options.IncludeIfNotExists = $True$scrp.Options.IncludeHeaders = $True$scrp.Options.ToFileOnly = $True$scrp.Options.Indexes = $True$scrp.Options.WithDependencies = $True $scrp.Options.FileName = "D:\PSScripts\NWind.SQL"$scrp.Script($dbs["Northwind"].Tables) I changed the instance, database, and file paths[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null $s = new-object ('Microsoft.SqlServer.Management.Smo.Server') "LOCALHOST"  $dbs=$s.Databases #$dbs["AdventureWorks"].Script()  $dbs["AdventureWorks"].Script() | Out-File C:\temp\myscript.SQL   $scrp = new-object ('Microsoft.SqlServer.Manag

class files

What is the recommended method of writing and storing class files in VS 2008, I'm using a web application?Many thanks

Moving files from one document library to another problem.

Hi, I have a strange problem with trying to move a number of files progammatically from one document library to another. I have a workflow running in sharepoint, which throughout the progress of the workflow, updates a word document stored in a document library, titled "CR".  Within the CR library there may also be a folder title "CR X" where x is the number of the document.  This folder contains any files which have been attached to the CR document.  I.E, excel files, pictures etc. When the workflow completes, the document should be moved to another document library called "Archived" which has a folder named after the year, i.e 2010, which inside that, contains a folder called the name of the document.  All the attached documents should also be moved to this folder. So for example, a document structure could be parentweb\parentsite\CR\CR 2.doc parentweb\parentsite\CR\CR 2\image.jpg parentweb\parentsite\CR\CR 2\image2.jpg Should, when the workflow completes end up looking like: parentweb\parentsite\Archived\2010\CR 2\CR 2.doc parentweb\parentsite\Archived\2010\CR 2\image.jpg parentweb\parentsite\Archived\2010\CR 2\image2.jpg. I have got the first part working fine, where the document is moved to the archive directory.  But I cannot move all the attachment files.  The loop I have to get the files and move them will wo

Problem importing text files with binary zeros (0x00) via SSIS(SQL2005). It is all fine when using D

Hi.   There is a "text" file generated by mainframe and it has to be uploaded to SQL Server. I've reproduced the situation with smaller sample. Let the file look like following: A17     123.17  first row          BB29    493.19  second             ZZ3     18947.1 third row is longer And in hex format: 00:  41 31 37 20 20 20 20 20 ? 31 32 33 2E 31 37 20 20  A17     123.17  10:  66 69 72 73 74 20 72 6F ? 77 0D 0A 42 42 32 39 20  first row??BB29 20:  20 00 20 34 39 33 2E 31 ? 39 20 20 73 65 63 6F 6E     493.19  secon30:  64 0D 0A 5A 5A 33 20 20 ? 20 20 20 31 38 39 34 37  d??ZZ3     1894740:  2E 31 20 74 68 69 72 64 ? 20 72 6F 77 00 69 73 20  .1 third row is 50:  6C 6F 6E 67 65 72       ?                          longer          I wrote "text" in quotes because sctrictly it is not pure text file - non-text binary zeros (0x00) happen sometimes instead of spaces (0x20).   The table is: CREATE TABLE eng ( src varchar (512) )   When i upload this file into SQL2000 using DTS or Import wizard, the table contains: select src, substring(src,9,8), len(src) from eng <               src                ><substr>             <len> A17     123.17  first row           123.17                  25BB29                                493.19                  22ZZ3     18947.1 third row           18947.1                 35   As one can see, everything was importe

"designer" problem- can't find the files

i got a project (.NET website) from another developer, unlike my project, every page has three parts- the aspx page, the cs page and a "designer" page. i tried to run the web site but i get error problem- "could not load .... type", it looks like the builder can't connect the designer file to the right page. how can i solve the problem can i link the page and the designer...

Problem Saving Files to A Sharepoint 2010 Site from Office 2010: Saves locally by default rather tha

Hi we are starting to use sharepoint 2010 / word 2010 and have found an interesting bug/problem. Sometimes when a user tries to save a file (by clicking on the save button in the quick access toolbar for word 2010) the save dialog comes up with the users local "Documents" folder as the path (not the correct sharepoint path where the document should be saved).  (I should say that we are creating the file from sharepoint by using a toolbar on the document library, with the new button)  We are using a content type and a template attached to the document library when we create the file.  This is really annoying because the user might not notice that the document is saving locally and not to sharepoint.  I have found a strange workaround which involves clicking the [File] tab on the ribbon in word 2010, then clicking "Save and Send" and then clicking the save button again.  At this point word 2010 seems to "remember" that it is trying to save document to sharepoint and shows the sharepoint document library. This is a real nuisance which could lead to documents being lost/misfiled if people don't realize that this is happening.  Can anyone help me? Thanks Kevin krd

Sending Array of Custom Class over WCF Problem

I have been attempting to convert some service calls that returned a DataSet into something more lightweight. For instance, I am converting: [OperationContract] public DataSet GetCommittees(); into: [OperationContract] public List<VolunteerCommittee> GetCommittees(); where committee is defined as: [DataContract] public class VolunteerCommittee { [DataMember] public int Id { get; set; } [DataMember] public String Name { get; set; } } I copied the structure of the data contract and the operation contract right from an example in a book I bought on WCF. The author mentioned that the List<VolunteerCommittee> would get converted into an array over the wire, so the client's operation contract looks like: [OperationContract] public VolunteerCommittee[] GetCommittees(); My problem: When the service is called, an empty array is returned every time. When I put trace statements in, I see an array of 48 VolunteerCommittees leaving the server. I've done some reading on the problem and tried a number of suggestions, such as using the XmlSerializer attribute, including a certain namespace as a [return:] on the server's contract, changing the type of binding (it's using wsHttpBinding... I tried basicHttpBinding) and turning off MTOM in the behavior, but none of these changed the empty result of the call. At this point, I'm hoping someone can shine some light on

Dithering problem with Bitmap class

I have a scanned document(black and white in color), which is typed through a word processor. So, I each letter is very crisp in the image and is not overlapping with any other character. But once I load that into Bitmap class I see that because of dithering the words get connected by gray color.   How can i make sure, that when we are loading the image in Image or Bitmap class we can avoid dithering at all. It means that if the system can find the exact color then map it otherwise leave the pixel untouched and dont fill any color(let's say leave it as white).  suneeelid2000@gmail.co

Document Set - Problem when uploading multiple files with "Launch forms in a dialog" disabled

Hello, Has anyone come across this before? I have a basic document library for which I have enabled "Allow management of content types" and disabled "Launch forms in a dialog".  Both of these settings are in the "Advanced Settings" page.  Also, the document library does not have versioning enabled and check out is not required. I added the OOTB "Document Set" content type to this document library and allowed OOTB "Document" content type documents in this document set.  This document set does not have any default content. The issue arises after I upload multiple files and click the "Done" button.  After I do this, the browser redirects to the top level of the site!  For example, if I uploaded to my document set at http://server/sites/anyname/doclib, I am redirected to http://server/. This issue has come up in both a standard server and an enterprise server. Steps to repeat issue: Create a document set Open the document set Select "Upload Multiple Documents" Drag and drop or browse for files Click "OK" Click "Done" Actually, this issue also occurs when "Launch forms in a dialog" is enabled.  In this case, you just have to navigate to the upload form directly (with all the necessary query string parameters, of course). Has anyone else seen this issu

problem in newform.aspx override class

Hi All Im facing a wierd problem, I have a custom list, im trying to override its newform.aspx page class with custom class. in Page_load event of the class Im checkig for one value in query string, if value exists then I have to select a dropdown field in the list. other wise not to select any value. After that i save the record.  Here only the PROBLEM comes. when I use my code it is NOT inserting new record. When I comment my code it is inserting new record. I do not understand whats the problem in my code. PLEASE help me to overcome this. Here is the code protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //When ERID is not null, it means request is coming from employee page if (HttpContext.Current.Request.QueryString["ERID"] != null) { FinishMyJob(); } } private void FinishMyJob() { SPSecurity.RunWithElevatedPrivileges(delegate() { string _StaffAppRecId = null; Boolean _IsFound = false; SPWeb _web = SPContext.Current.Web; SPList _list = _web.Lists[SPContext.Current.ListId]; SPList _lstEmp = _web.Lists["Employee"]; SPListItem _EmpLstItem = _lstEmp.GetItemById(Convert.ToInt32(HttpContext.Current.Request.QueryString["ERID"])); string _strEmpName = Convert.ToStri

Problem with HijriCalendar class

The minimum supported date for HijriCalendar class is 1/1/1 which is equivalent to the gregorian date of July 18th, 622. Now when I try to pass that date to HijriCalendar.GetYear with HijriAdjustment set to -1 I get the following exception  [ArgumentOutOfRangeException: Valid values are between 1 and 9666, inclusive. Parameter name: year] System.Globalization.HijriCalendar.GetDaysInYear(Int32 year, Int32 era) +5405139 System.Globalization.HijriCalendar.GetDatePart(Int64 ticks, Int32 part) +199 System.Globalization.HijriCalendar.GetYear(DateTime time) +41 Here is the code to reproduce the problem: private static void TestHijriAdjustment(int adjustment) { HijriCalendar calendar = new HijriCalendar() { HijriAdjustment = adjustment }; try { Console.WriteLine("HijriAdjutment = {0}, Year = {1}", adjustment, calendar.GetYear(calendar.MinSupportedDateTime)); } catch(ArgumentOutOfRangeException ex) { Console.WriteLine("HijriAdjutment = {0}, Exception: {1} ", adjustment, ex.Message); } } static void Main(string[] args) { TestHijriAdjustment(-2); // Prints Year = 0!! Why doesn't it throw an exception? TestHijriAdjustment(-1); // Throws exception TestHijriAdjustment(0); // Prints Year = 1 TestHijriAdjustment(1); // Prints Year = 1 TestHijriAdjustment(2); // Prints Year = 1 } Now the reason I want minimum supported date t

Problem in debugging a class library


When I try to debug a class library I am getting an warning message "Unable to automatically step into the server. Connecting to the server machine 'xxxx.xxx' failed. The debugger cannot connect to the remote computer. This may be because the remote computer does not exist or firewall may be preventing communication to the remote computer. Please see help for assistance."

After getting this message my application shows the result set from the web service. I am not trying to debug the web service application, but trying to debug my code which is in another project in the same solution. Also I have added the project reference from my test application not the dll reference. I've checked the windows firewall and added exception for port 80 also.

Any help in this regard will be greatly appreciated.




spmetal generated class and content type (for page layout) retrieve problem


I'm working with a console application to generate my sites and subsites (hierarchy). And i've got a problem with a generated spmetal class.


this doesn't work:


static void Main(string[] args)


            string SITE = string.Concat("http://"Environment.MachineName);         



Unusual problem using a class method


I have a class that runs calculations on numbers and populates the results to my SQL database.  My code behind page instantiates the class object, and in a loop it makes use of the method five times (once per loop).  Essentially, my code behind collects the information from controls and passes the information to the class method for processing.  The method works just fine most of the time.

On one of the iterations I get a error before the code even gets to the class.  The error is, "Arithmetic operation resulted in an overflow."  What strikes me as odd is that while stepping through the code, the loop crashes with that error before getting to the class that runs the calculations.  Additionally, no arethmetic operations are performed on the form's code-behind page (which calls the method).  I even put a break-point on the class constructor but the code crashed before reaching that constructor.

The information being sent is the results of matches from a sporting event.  As a troubleshooting measure I changed the order of the matches by deleting them an re-entering them into the database in a different order.  Again only this one particular match crashed.

Here is the code that crashes:

cRating.SetRating(dMatchDate, iSetID, 8, iHPlayerID, 

Problem with class hierarchy in MVC app



What have I omitted in setting up my MVC project correctly ?

When I use an imports statement, at the top of my controller(s), I have to repeat the project name twice in order to include my model :

Imports PartInvitations.PartInvitations.Models






2010 Collection class syntax/property problem

I converted a project from 2008 to 2010 to be able to use the TPL.

I've updated the compile target to .NET 4. Everything seems good, including the .NET 4 specific TPL stuff...except that:

Parallel.ForEach(MyClassCollection.Cast(Of MyClass), (Sub(ANYTHING As MYClass) ANYTHING.MySubRoutine()))

Gives the following as a syntax error:

Error 2 'Cast' is not a member of 'Microsoft.VisualBasic.Collection'. C:\Users\jeff\Documents\Visual Studio 2010\Projects\MyProject\MyProject\RunLoop.vb 229 34 MyProject

Any ideas?

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