vb.net

How to convert ArrayList to an array of structure?

Here I have: Public Structure MyStruct Public Name as String Public Content as String End Structure Dim oStruct as MyStruct = New MyStruct() oStruct.Name = ... oStruct.Content = ... Dim alList as ArrayList = new ArrayList() alList.Add(oStruct) I'd like to convert the ArrayList to a static strongly-typed Array of type MyStruct....

VB.NET generics to C# syntax

Could you please show me the C# Equivalent of this VB.NET code: Public Partial Class Index Inherits System.Web.Mvc.Viewpage(Of List(Of Task)) End Class I am not sure where/how to add it in for C#: public partial class DirList : System.Web.Mvc.ViewPage { } The code is suppose to tell the class to expect a list of tasks from t...

VB.NET Strong-typed collection

I want to create a collection in VB.NET, but I only want it to accept objects of a certain type. For example, I want to create a class called "FooCollection" that acts like a collection in every way, but only accepts objects of type "Foo". I thought I could do this using generics, using the following syntax: Public Class FooCollect...

Database backup of a mysql database in VB.Net.

How do you create a database backup of a mysql database in VB.Net? ...

Best way to maintain a customer's account balance.

Is it better to have a field in the database that stores the customers account balance or use views and queries to generate the information. ...

Enum Parameters

I am hoping to find a way to do this in vb.net: Say you have function call getPaint(Color). You want the call to be limited to the parameter values of (red,green,yellow). When they enter that parameter, the user is provided the available options, like how a boolean parameter functions. Any ideas? ...

Which .Net Timer() to use

I have a legacy WinForms Mdi App in VB.Net 2.0 which I am adding functionality to. One of the additions is a warning which needs to be raised when the current time nears a specified value (a deadline). My intention is to check the time once an hour until there is less than an hour until the deadline, then display warnings at specified in...

LIKE in Linq to SQL

I have a method that needs to accept an array of country names, and return a list of records that match one of those country names. I'm trying this Public Shared Function GetConcessions(ByVal Countries As String()) As IEnumerable Dim CountryList As String = Utility.JoinArray(Countries) ' turns string array into comma-separated stri...

#warning directive in VB.net

I know the #warning directive does not exist in vb.net... is there anything like it? I want to be able to throw messages (warnings) at compiler time. ...

.NET webservice using an instance of a parameter type?

I have a Windows forms project and a Web Service project in my solution, and I'm trying to call the web service and return a customer object as the result. The problem is that when I try to receive the return object, I get an error that it can't convert it. For example, here is the signature for my webservice: Public Function GetDriverB...

Building a Decoupled N-Tier App With Entity Framework and VB.NET

So we are building an application with a UI Layer (web, mobile, Ajax client, etc) Service/API Layer Business Logic Layer Data Access Layer Our goal is to have an Entity Framework dependency from the Service Layer on down to the DAL. That means the Sevice layer will only accept and return POCOs (plain old CLR objects). What we're ...

Passing data between business layer and data access layer - bad code?

I'm using the following code within the JCProperty class to retrieve data from a DAL: Dim x As JCProperty x = JCPropertyDB.GetProperty(PropertyID) If Not x Is Nothing Then Me.PropertyID = x.PropertyID Me.AddressLine1 = x.AddressLine1 Me.AddressLine2 = x.AddressLine2 Me.A...

Explaining Anonymous Types to people used to Variants

For the last year and a half we've gotten been working on a large WPF application and it's finally exiting beta and moving to full release. When we started the project, I fought hard for every assembly to use Option Strict. My team had little .NET experience prior to this project, and alot of experience with Visual Basic 5 where nearly e...

What is the best way to mix VB.NET's Option Strict and the new Option Infer directives?

In a related question, my team is about to (hopefully) start using LINQ, and I'd like to take advantage of anonymous types. What is the best way to mix VB.NET's Option Strict (which we've been using through the life of the project) and the new Option Infer directives? ...

Adding spaces between strings

Hi, What's the best way of adding spaces between strings myString = string.Concat("a"," ","b") or myString = string.Concat("a",Chr(9),"b") I am using stringbuilder to build an XML file and looking for something efficient. Thanks Edit ~ Language VB.NET ...

ASP.NET OleDbConnection Problem

I'm working on an ASP.NET website where I am using an asp:repeater with paging done through a VB.NET code-behind file. I'm having trouble with the database connection though. As far as I can tell, the paging is working, but I can't get the data to be certain. The database is a Microsoft Access database. The function that should be acces...

Button generated for each item in an XSLT file runat server

I am tryiing to create an "add to cart" button for each item that is displayed by an XSLT file. The button must be run at server (VB) and I need to pass parameters into the onlick, so that the requested item is added to the cart. Is this possible, and if so, how should I go about it? When I try <asp:Button id="Button123" Text="Add t...

Do you use the 'My' namespace in VB.NET?

VB.NET has the "my" namespace, but how many VB.NET developers actually use it? if you don't, why? if you are using it, why? I'm considering building a framework for VB.NET, and using the My namespace to plug it into VB seems like a reasonable idea. Is it? ...

What's the best way to use SqlBulkCopy to fill a really large table?

Nightly, I need to fill a SQL Server 2005 table from an ODBC source with over 8 million records. Currently I am using an insert statement from linked server with syntax select similar to this: Insert Into SQLStagingTable from Select * from OpenQuery(ODBCSource, 'Select * from SourceTable') This is really inefficient and takes hours to...

How to navigate between fields with Enter Key

My company has a large application written in VB6, and for historical reasons, the application is navigated with the Enter key instead of with the Tab key. I don't know VB6, but I know that they currently set the focus for each control in a big select statement in the Form's KeyUp event if it's an EnterKey. Now we are starting to conve...