Code Review: ADO.NET Data Access Utility Class (VB)?
Mar 6, 2009
When I started at my current employer I inherited a project from a previous developer and in that project was a data access utility class that tries to simplify a lot of the code involved in making calls and retrieving data back from the database. Over time it has been modified to add more overloaded forms of functions, and now I am looking at possible suggestions from the StackOverflow community.What do you think should be added? Removed?odified?Note:It would be nice if this class could remain compatible to VB.NET in the .NET 2.0 framework. We are also developing in 3.5, but I would like to have something that is generally going to work across most frameworks (so no LINQ, etc.) Also, please refrain from unnecessary answers that consist of nothing but "Use nHibernate" or other tools.
My class:
Public Class DataAccess
Public Shared Function ReturnScalar(ByVal CmdStr As String) As String
[code].....
View 2 Replies
ADVERTISEMENT
Nov 6, 2010
Anyone here kind enough to give me a code review on the following pattern that I have used for database access? I have provided one of the simpler datalayers to show the basic idea.In particular I am starting to question if using shared methods was a good idea and what problems may arise from that? Will this implementation fail in a threaded environment like ASP.Net?
Public Interface IFillable
Sub Fill(ByVal Datareader As Data.IDataReader)
End Interface
[code].....
View 1 Replies
Jan 19, 2011
Anyone here kind enough to give me a code review on the following pattern that I have used for database access? I have provided one of the simpler datalayers to show the basic idea.In particular I am starting to question if using shared methods was a good idea and what problems may arise from that? Will this implementation fail in a threaded environment like ASP.Net?
[Code]...
View 1 Replies
May 7, 2009
I downloaded this code from the web that Wierddemon gave me in my previous thread. This solution contains 2 projects (CurrencyControlTest and CurrencyTextBox) There are some things that I don't understand:
1. What's the type of form1.vb and program.vb in the CurrencyControlTest Project? Are they classes, or windows Forms or module?
2. This is the code in Program.vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
[CODE]...
What's the effect of <STAThread> code?
3. What is exactly the "Namespace" doing in this code? because when I removed the namespace, An error indicating that Form1 is not declared appeared. What is namespace? what does it do? Can anyone give sample code to emphasize the function and how and when to use the keyword "Namespace"?
4. This is code for Form1 in CurrencyControlTest Project
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
[CODE]...
What's with the "public partial class Form1"? what does "partial" do? When i right-clicked on the InitializeComponent(), A portion of code appeared suddenly with the header #Region. What is this? and when re-open the Form1 in "View Code" mode, they're gone.
View 7 Replies
Nov 30, 2009
With a function being passed a full path to a file, such as C:someFolderanotherFoldersomeXML.xml, determine whether the folder exists. Is there a smarter/better/more elegant way of doing this? Here is my implementation:
[code].....
View 2 Replies
Dec 4, 2011
I am using C# to develop an enterprise level application. I use VS2010 Modeling Project to model my classes but there is no code generation utility which available for free. I want to know if is there any Utility/Extension that can generate C#/VB code from UML diagrams.
View 2 Replies
Dec 2, 2011
How to include a custom utility class with our T4 templates generators ? I tried adding a module to the project but it seem there is no way to include it for my generators to use the methods from it.
View 2 Replies
Feb 15, 2011
I have a very simple class that is located within my App_Code folder in my VS2008 web application project. I am trying to instantiate an instance of this class from my code-behind file. Intellisense does not seem to be seeing my class and I am not sure why. I am using VB.NET which I am admittedly not that familiar with as compared to C#. Perhaps I am missing something. I would bet it has something to do with something I am missing in VB.NET.Here is my simple class (for testing):
[Code]...
View 2 Replies
Mar 30, 2012
I have a CodeSmith 6 project setup in Visual Studio. I added a class with a shared method (VB), but cannot refer to it in my template. I also tried adding an assembly reference to the project DLL, but that didn't work either. How can I use my own utilities like this?
View 1 Replies
Jun 25, 2012
I want to find a way to speed up this code.if you look at the condition of If calculated Then in the code below, this is what slowing down the code.While the code provided seem fast with Const initBit = 4 try it with something over 12.
I want to be able to use this code (with calculated param as True) with initBit of 20 or more.
Beware that 20 or more might require a gig or more of ram and/or compiled as x64.
C# code (converted with an online tool from VB.NET):
[Code]...
View 2 Replies
Sep 3, 2009
I am looking for some (preferable vb.net) code to use in an asp.net application that will allow me/my users to setup calendars (that I store in SQL server db).
I am looking for something that will make it easy to schedule recurring appts (i.e. every monday, every other week on thursday at 9AM, every month,1st and 3rd tuesday, every year etc) with as many possible scenarios as possible.
I can automate most of the easy ones via a few screens, but inevitably my users come up with scenarios that require me to code and execute some custom scripts in SQL to make the entries, and I'd really like to offload this to the users.
View 1 Replies
Jan 11, 2012
How to access controls from class files in app code?
Markup:
<%@ Page Language="vb" AutoEventWireup="false" Inherits="shoppingCart1.ShoppingPage" CodeFile="ShoppingPage.aspx.vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
[Code]...
View 2 Replies
Oct 21, 2010
I have a web site project in which I added a "Class.vb" file to hold public functions/procedures/variables. I'm trying to access a function within this file from my code-behind file from an aspx page. I've called the Class file "Module1"; Publc Class Module1.[code]...
View 3 Replies
Apr 13, 2012
A few years ago we (as a company) faced the scenario of getting our developers to stop writing classic asp pages and switch to .net (and in turn system.data for data access). As a supposedly ˜short term measure I wrote the following class to make the switchover easier for those not used to system.data & all its new objects: [URL] The main purpose of this class was to keep usage as similar to classic asp as possible & keep the usage VERY simple (plus to add email alerts for error catching yada yada yada):
[Code]...
View 2 Replies
Mar 14, 2010
I would like to build a base class for my SQL Data Access Layer. I have most of it based out, but have a question about how to handle errors within the base class. I have a method for ExecuteNonQuery, ExecuteReader, ect...
[Code]...
View 18 Replies
Mar 31, 2011
I've got a program where the insert/update SQL was created with the values coded directly into the SQL string. I've changed this to use the Command's Parameters.AddWithValue method and all worked well. I'm now in the process of separating the data access code out into it's own class. I've got the Select code working using a DataSet in the form that I pass ByRef to my data class so it can populate or refresh it. My sticking point is in how to pass the parameters for the Insert/Update commands to the class since from the form I no longer have access to a Command object. Do I need to make the Command object in the data access class available to the form?
View 6 Replies
Apr 20, 2010
I'm currently working on my VB.NET certification and I'm using Murach's Visual Basic 2008 for my class textbook. Chapter 16 of the text covers writing my own ADO.NET data access codes. The code I have included here is for two classes of the project:
frmAddModifyCustomerDB.vb is prewritten by murach for this assignment and CustomerDB.vb is included written in the book as my assignment to build but not prewritten for me in the solution. According to the assignment, frmAddModifyCustomerDB.vb should not be modified unless instructed by the book. The procedure in question is Private Sub btnAccept_Click on the line that reads: "If Not CustomerDB.UpdateCustomer(customer, newCustomer) Then".After copying the CustomerDB.vb class directly from the book the assignment stated that the database should update properly when using the UpdateCustomer function that is fired when the Accept button is clicked. Every time I tried to modify a customer when doing this I kept getting the Database Error message box and the changes would be canceled.
After playing with the code I changed the "If Not CustomerDB.UpdateCustomer(customer, newCustomer) Then" to check against the boolean return from CustomerDB.vb by inserting "= False". When the modified code reads "If Not CustomerDB.UpdateCustomer(customer,
newCustomer) = False Then" the application updates properly and does not fire any exceptions. I'm confused by this because the book specified that I should not need to modify the code for the Add/Modify form in order for this to work.
Public Class frmAddModifyCustomer
Public addCustomer As Boolean
Public customer As Customer
[code].....
View 3 Replies
Jun 2, 2011
I Have code for display excel data in datagriedview can anyone suggest me how i can export this data to ms-access tables.
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim DtSet As System.Data.DataSet
[code]......
View 1 Replies
Feb 10, 2011
I can access a module from code behind but not from the aspx page in inline VB code <% ... %>.
View 2 Replies
Sep 21, 2010
I have an application half built which accesses a Access (2003)Database File. From within the application I am able to change the data in the Access File using a Data Grid. The changes to the Data File are saved and can be recalled, changed or otherwisemanipulated however, when I add too or change any of the applicationcode the Access file reverts back to it's original state losing any data or changes that has been made.
View 3 Replies
Mar 13, 2009
Here is the:
Imports System.Data.OleDb
'Add reference to Access then
Imports Microsoft.Office.Interop
Imports Microsoft.VisualBasic
[CODE]...
I am using this to copy tables in an Access database(2003). the questions I have are:
1. How can I make this more 'obejct oriented'?
2. How can I copy just the structure of the tables and not the data?
(Currently both are occuring)
View 3 Replies
Aug 1, 2011
I have multiple documents stored in Attachment data type in Access database. UsingDataReader, I need to read multiple attachments along with their file name and store them on the file system
View 1 Replies
Jan 24, 2009
I have the following XML Doc.[code]....
I need to accomplish the following:
when TYPE =CH and STATUS=LI then I need to get the values of REVIEW NUM and also the value of CHECK->ISSUE_DATE. here is what I have so far that is not working very well[code]......
View 6 Replies
Oct 19, 2009
I have an application that I want to review existing word documents. What I mean by review is that they can look at them and print them and that is about it. I am a bit stuck on how to complete this task though. I tried using a web browser and that allows changes and with a very minor bit of work the document can be modified and saved. I also tried using process.start and that just starts up the word application as does SetParent.
Is it possible to just take snapshots of the document and view those? Or to open the document as a readonly document?
View 5 Replies
Aug 18, 2009
I have some classes, BsfciFile and StudyFlashCard. Bsfci is the extension to which I save my set of flashcards in an INI format. I am currently working to transform my code from using Windows API calls to access the INI to using a IniFile class that I found on the internet. I would like the BsfciFile to have a Array of StudyFlashCard objects, but I would like the StudyFlashCard class to use the IniFile class object contained in the BsfciFile class. I can pass the IniFile from the BsfciFile class to the constructor for the StudyFlashCard class, but I want it to modify the same IniFile as the BsfciFile class has later on.
[Code]...
View 1 Replies
Mar 1, 2010
I need to create unit testing project for my current website. The currentw ebsite si written in VB. All unit testing examples are using interface to create mock object. My current VB class does not implment any interface. Can I add interface and implement it to my current class and functions without affecting or changing codes to any pages in my website that call the functions? For examples my current class is like:
[Code]...
View 2 Replies
Mar 31, 2009
Basically I have a test tomorrow in CPS 110, my programming class that I am completely lost in. I plan on becoming a network admin and not a programmer but I had to take the class. Anyways, here is the email of the review my professor sent me. Following that I am going to say what I need help with.
CPS 110 Spring 2009 (Singh) Review topics for Test 2(You are expected to remember the previous stuff: datatypes,if / if-else statements and booleans).I. Select case statements: write code/walk through
II. Strings and built-in methods. You CAN use the handout about strings and characters from class on the test.
[Code]...
View 7 Replies
Jan 18, 2011
my proble is the following: I have a class MyClass and another class Modifier, which has a method ModifyMyClass(ByRef mc as MyClass) that receives a MyClass instance as ByRef parameter to modify it. A smell of the code is:
[Code]...
View 4 Replies
Mar 30, 2010
This is a bit of a continuation from a previous post for which AtmaWeapon was very informative.
Problem:
A parent class has a sub class with various properties. A property of the parent class is a List(of T) with T = the sub class The issue is how to store data in the sub class of the instantiated parent
Some example code (hopefully formatted correctly):
Code:
'=========== Class Definitions =============
Public Class courseClass
Public Class timeTableClass
[Code].....
View 7 Replies
Oct 22, 2010
How do I access the base class inside a derived class?
View 1 Replies