Onteora Software

Ken Tucker's Blog
posts - 145, comments - 623, trackbacks - 0

September 2007 Entries

South Florida Code Camp

South Florida Code Camp I went to the south florida Code Camp and did a session on Windows Forms Datagridview. I talked about the new features in VS.Net 2005 and customizing the datagridview. You can find the powerpoint presentation and the code on my vb-tips website. If you have any questions please feel free to email me. I have been real busy lately and not have gotten a chance to blog in a while. I have gotten involved with project to create a webhost company KJM Solutions. We will be offering SQL Server 2005 and Asp.net 2.0 hosting hope to be...

posted @ Saturday, September 22, 2007 3:12 PM | Feedback (0) | Filed Under [ Camp ]

Silverlight XAML 404 errors

Silverlight XAML 404 errors I created a simple web application which uses silverlight. Once I was happy with the way it was working I deployed to my webhost. When the web page loaded the silverlight control is not displaying anything.   Fidder 2 lets you examine what is going on when a webpage is loading. I see that there is a 404 error when loading the xaml file being displayed in the silverlight control. When I log into my webhost's control panel I see the xaml file is there.   According to Tim Heuser's blog all you have to do is Mime type...

posted @ Friday, September 21, 2007 9:39 AM | Feedback (1) | Filed Under [ Silverlight ]

Russ Fustinos Tool Shed Tour

Russ Fustino's Tool Shed Tour

posted @ Friday, September 21, 2007 7:38 AM | Feedback (0) | Filed Under [ Events User Group ]

Use the AjaxSlideShowExtender to show pictures in a directory

Use the AjaxSlideShowExtender to show pictures in a directory The AjaxSlideShowExtender will automatically display a slide show in an image control.  The slide show extender calls a shared function to get a list of slides.  This tip shows hows to create slide of all the images in a folder. The Pages HTML <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title>Untitled Page</title> </head> <body>     <form id="form1" runat="server">         <asp:ScriptManager ID="ScriptManager1" runat="server" />         <div>             <div style="text-align: center">                 <asp:Image ID="Image1" runat="server" Height="300" Style="border: 1px solid black;                     width: auto" ImageUrl="images/ajax.jpg"                     AlternateText="Ajax" />                 <asp:Label runat="Server" ID="imageLabel1" /><br...

posted @ Sunday, September 16, 2007 9:35 PM | Feedback (2) | Filed Under [ Ajax ]

Sql Endpoint and DataGridView

Sql Endpoint and DataGridViewSQL Server 2005 allows you to create webservices for accessing the data in a database.  These webservices are call SQL End Points.  Lets start by creating a stored procedure to get the contact name and there titles for all the customers in the northwind database.   Create PROCEDURE [dbo].[GetContacts] AS BEGIN     SET NOCOUNT ON;     SELECT [ContactName],[ContactTitle] FROM Customers ORDER BY [ContactName]; END Now we can create the end point.  Note for this example I am using port 88 for the end point to prevent errors if you have IIS installed. CREATE ENDPOINT NW_Contacts     STATE = Started AS HTTP     (         PATH = '/Contacts',         AUTHENTICATION = (INTEGRATED),         PORTS = (CLEAR), CLEAR_PORT = 88,         SITE = '*'     ) FOR SOAP     (         WEBMETHOD 'GetContacts'             (NAME...

posted @ Sunday, September 16, 2007 6:36 PM | Feedback (0) | Filed Under [ DataGridView Sql ]

Vista Task Dialog

Vista Task Dialog Windows Vista has some cool looking new Dialog's. This example will show how to use the TaskDialog an improved message box with Visual Studio 2005.   Public Class Form1     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Dim x As Integer         TaskDialogHelper.TaskDialog(Me.Handle, IntPtr.Zero, "Title", "Are you sure?", "This is a test", TaskDialogHelper.TaskDialogButtons.Ok, TaskDialogHelper.TaskDialogIcon.Question, x)     End Sub End Class Public Class TaskDialogHelper     Public Enum TaskDialogButtons         Ok = &H1         Cancel = &H8         Yes = &H2         No = &H4         Retry = &H10         Close = &H20     End Enum     Public Enum TaskDialogIcon         Information = UInt16.MaxValue - 2         Warning =...

posted @ Sunday, September 16, 2007 6:17 PM | Feedback (1) | Filed Under [ Vista ]

Getting the Back Button to work with Ajax

Getting the Back Button to work with Ajax Microsoft's Asp.Net Ajax makes it easy to create a web page that can refresh itself with out posting back.  Unfortunately when a web page updates itself using ajax the user is unable to press the back button to get back to what is was on the page before.  In this article I will first show to create an ajax enable website which uses a webservice to update itself. Then we will make the back button work properly.   First create a new AjaxEnabledWebsite and lets start off by adding a webservice to the Project named Customers.  This...

posted @ Sunday, September 16, 2007 6:01 PM | Feedback (1) | Filed Under [ Ajax ]

Microsoft Visual Basic 2005 Power Packs

Microsoft Visual Basic 2005 Power Packs Visual Basic 2005 Power Packs are free Add-Ins, Controls, Components, Tools or Samples for you to use with Visual Basic 2005 to make developing great applications even easier! Microsoft Interop Forms Toolkit 1.0 This toolkit is aimed at simplifying the use of Visual Basic.NET WinForms within a Visual Basic 6 application. The toolkit is targeted specifically at providing tools and guidance for performing a phased migration of a VB6 forms-based application to VB.NET. The goal of a phased migration is a production release at the end of each phase that has both VB6 and .NET...

posted @ Sunday, September 16, 2007 5:55 PM | Feedback (0) | Filed Under [ VB ]

Active Directory users

Active Directory users There is no way to get a users password from an active directory. One of the DirectoryEntry constructor overloads allows you to specify the username and password. To see if the user name and password are correct try and create a directoryEntry object with the given username and password. If the password username combination are incorrect you will get an exception. Here is a sample function to authenicate a user.  Public Function Authenicate(ByVal username As String, ByVal password As String) As Boolean         Dim isValid As Boolean = False         Try             Dim de As New DirectoryServices.DirectoryEntry("LDAP://YourActiveDirectoryName", username, password, _                     DirectoryServices.AuthenticationTypes.Secure...

posted @ Sunday, September 16, 2007 5:33 PM | Feedback (1) | Filed Under [ VB ]

Orlando Code Camp

Orlando Code Camp I signed up to do two sessions at the Orlando Code Camp on March 25, 2006. I am doing a session on Windows Forms Datagridview, and another on the LINQ project. The LINQ project is a preview of a technology to be introduced in the next version of Visual Studio.

posted @ Sunday, September 16, 2007 3:41 PM | Feedback (1) | Filed Under [ Camp ]

Vista: Get WinSat Info

Vista: Get WinSat Info Windows Vista has a performance index for your hardware.  The scores range from 1(worst) to 5.9(best).  If your application uses a lot of graphics you might get poor performance on a computer with a graphics score of 1.  You can use this number to scale back on the graphics to improve your apps performance.  This example gets displays the scores in the forms paint event.  For this example add a reference to the WinSat 1.0 type library in the com tab. Imports WINSATLib Imports System.Text Public Class Form1     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load    ...

posted @ Sunday, September 16, 2007 3:41 PM | Feedback (1) | Filed Under [ VB Vista ]

Binding to a WPF Listbox Part 2

Binding to a WPF Listbox Part 2 In this example we will group the data in the WPF Listbox with CollectionView class.   We will add a GroupStyle which will allow us to expand or hide the grouped data.  We will start off by making a List which contains an Animals class.  Then we create a ListCollectionView from the list.  Finally we create an CollectionView from the ListCollectionView and add a GroupDescription to it.  Then we bind the ListBox to the CollectionView Pages XAML <Window x:Class="Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="Window1" Height="300" Width="300">  <Window.Resources>   <DataTemplate x:Key ="lstItem" >    <StackPanel>      <TextBlock Text="{Binding Path=Animal}"/>    </StackPanel>   </DataTemplate>  </Window.Resources>   <Grid>   <ListBox Margin="14,15,47,34" Name="ListBox1" ItemTemplate="{StaticResource lstItem}" >    <ListBox.GroupStyle>     <GroupStyle>      <GroupStyle.ContainerStyle>       <Style TargetType="{x:Type GroupItem}">        <Setter Property="Margin" Value="0,0,0,5"/>        <Setter Property="Template">         <Setter.Value>          <ControlTemplate TargetType="{x:Type...

posted @ Sunday, September 16, 2007 3:40 PM | Feedback (0) | Filed Under [ WPF ]

Using XLinq to get a list of Photos from Spaces.Live.com

Using XLinq to get a list of Photos from Spaces.Live.com Storing photo albums on line is becoming very popular. Spaces.Live.com photo is one place to store albums which exposes its photo albums via an rss feed. I thought it would be nice to test out Visual Studio 2008 XLinq by getting a list of Photo's from the Tampa Code Camp and display them in WPF Listbox. The photos I am looking for can be found here. http://thedevfish.spaces.live.com/photos/cns!75364D9E73295107!133/feed.rss The xml in the rss feed exposes each photo like this     <item>       <title>volunteers arrived at 630am - nikita polyakov [mvp] led them</title>       <link>http://thedevfish.spaces.live.com/photos/cns!75364D9E73295107!133/cns!75364D9E73295107!134</link>       <description><p><a href="http://thedevfish.spaces.live.com&#47;photos&#47;cns&#33;75364D9E73295107&#33;133&#47;cns&#33;75364D9E73295107&#33;134" mce_href="http://thedevfish.spaces.live.com&#47;photos&#47;cns&#33;75364D9E73295107&#33;133&#47;cns&#33;75364D9E73295107&#33;134"><img src="http://storage.live.com&#47;items&#47;75364D9E73295107&#33;134&#58;thumbnail"...

posted @ Sunday, September 16, 2007 3:39 PM | Feedback (0) | Filed Under [ Asp Linq ]

GotDotNet Phase out

GotDotNet Phase out Since the GotDotNet website is being phased out I am placing my user samples here . Video Capture Box A inherted picturebox control which allows you to capture an image from a webcam. Also adds a ByteImage Property to make it easier to bind to an image from a database. Enum Windows A module you can add to your projects which contains an enum with all the WM_ messages. Good to use when overriding wndproc.

posted @ Sunday, September 16, 2007 3:38 PM | Feedback (0) | Filed Under [ General ]

Create a VS 2005 Debugging Visualizer

Create a VS 2005 Debugging Visualizer Visual Studio 2005 visualizers allow you to see the data contained in a variable.  For this example we will create a visualizer to see the value of a guid.  To create a visualizer we need to start with a class library project.  Add a reference to Microsoft.VisualStudio.DebuggerVisualizers and System.Windows.Forms.  Set the build output path in the compile tab of my project to My Documents\Visual Studio 2005\Visualizers.  . Imports Microsoft.VisualStudio.DebuggerVisualizers Imports System.Windows.Forms <Assembly: DebuggerVisualizer(GetType(GuidVisualizer), target:=GetType(Guid), description:="Guid visualizer")> Public Class GuidVisualizer     Inherits DialogDebuggerVisualizer     Protected Overrides Sub Show(ByVal windowService As Microsoft.VisualStudio.DebuggerVisualizers.IDialogVisualizerService, ByVal objectProvider As Microsoft.VisualStudio.DebuggerVisualizers.IVisualizerObjectProvider)         Dim g As Guid...

posted @ Sunday, September 16, 2007 3:37 PM | Feedback (0) | Filed Under [ Debugging VB ]

July Space Coast .Net Meeting

July Space Coast .Net Meeting When: July 18 @ 6:30 PM Where:  Space Coast Credit Union Corp headquarters Connecting Applications with WCF Most applications of any scale need to make remote calls. Whether you need to call across processes from your smart client to a web service, from your web server to your application server, or from one client to another in a peer to peer fashion, WCF supports any kind of remote messaging or communications scenario. It doesn’t just stop at remote calls either, but also supports multiple forms of security, distributed transactions, queuing, concurrency, callbacks and many other things that are needed...

posted @ Sunday, September 16, 2007 3:37 PM | Feedback (0) | Filed Under [ Events User Group ]

VB 2008 Extension Methods

VB 2008 Extension Methods Visual Basic 2008 adds a new features called extension methods.   These allow you to add a method, or function to a type.  For this example we will add an IsGuid function to strings.  All extension methods must be placed in a module.  The function or method must be marked as an extension and the first argument is the type the method extends. Imports System.Runtime.CompilerServices Imports System.Text.RegularExpressions Module Module1     Sub Main()         Dim g As String = "82ee4145-632c-42a1-83b9-57ec163eaa17"         Dim g1 As String = "82ee4145-632c-42a1-83b9-57ec163ea17"         Console.WriteLine(g & IIf(g.IsGuid, " is ", " is not ") & "a valid guid")         Console.WriteLine(g1 & IIf(g1.IsGuid, "...

posted @ Sunday, September 16, 2007 3:36 PM | Feedback (2) | Filed Under [ VS 2008 ]

Live From Redmond Webcast Series

Live From Redmond Webcast Series The Visual Basic team has put together a "Live from Redmond" webcast series aimed at the next version of Visual Basic and Visual Studio code named "Orcas". The live series starts April 18th and will continue to the end of May. Come join the Visual Basic team for this exciting series. Here's the schedule (check the VB Developer Center for updates):  Live From Redmond: VB9 - Orcas Overview April 18th, Presented by John Stallo Live From Redmond: VB9 - LINQ Overview April 25th, Presented by Kit George Live From Redmond: VB9 - LINQ to SQL & O/R Designer Deep Dive May 2nd, Presented by Young Joo Live...

posted @ Sunday, September 16, 2007 3:34 PM | Feedback (2) | Filed Under [ Events VB ]

WPF Bind to a Method

WPF Bind to a Method In this part we will bind to a method. As we type a number into a textbox the results will be displayed in label below it. For this example we use a class which figures out the area of a circle. Let's start off with a class which calculates the area of a circle. This class has one function named CalculateArea. Public Class Area     Public Function CalculateArea(ByVal Radius As Double) As Double         Return Math.PI * Radius ^ 2     End Function End Class Now that we have a class set up to calculate the area we need 2 additonal classes. The first needs...

posted @ Sunday, September 16, 2007 3:34 PM | Feedback (1) | Filed Under [ WPF ]

WPF OneWay Binding Part 3

WPF OneWay Binding Part 3 In this part we will bind to a class. We will start off by creating a grid to display the properties of the class. Finally we will show how to get the form to update itself when a value changes in the class. Lets start off creating a class that shows some info about the computer. Here is the class. Public Class ComputerInfo     Public ReadOnly Property UserName() As String         Get             Return Environment.UserName         End Get     End Property     Public ReadOnly Property ComputerName() As String         Get             Return Environment.MachineName         End Get     End Property     Public ReadOnly Property UpTime() As Integer         Get             Return Environment.TickCount         End Get     End Property End Class Ok lets register the class with the form. <Window x:Class="Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:local="clr-namespace:WPFOneWayBindToVariable"     Title="WPFOneWayBindToVariable" Height="300" Width="300"     >   <Window.Resources>     <local:ComputerInfo...

posted @ Sunday, September 16, 2007 3:33 PM | Feedback (1) | Filed Under [ WPF ]

WPF OneWay Binding Part 2

WPF OneWay Binding Part 2 In the last part we bound a label to the value of the scrollbar. In this part we will format the scrollbar's value before we display it. To be able to format the output of a bound value you need a class which inherits from IValueConverter. For this example I am using the NumbersToWords function found here to convert the number to a word for display. Public Class NumberToWord     Implements IValueConverter     Private Function NumbersToWords(ByVal num As Decimal) As String         Dim power_value(5) As Decimal         Dim power_name(5) As String         Dim digits As Integer         Dim result As String         Dim i As Integer         ' Initialize the power names and...

posted @ Sunday, September 16, 2007 3:33 PM | Feedback (0) | Filed Under [ WPF ]

WPF OneWay Binding Part 1

WPF OneWay Binding Part 1 Windows Presentation Foundation (WPF) foundation is for building applications and experiences in Windows Vista that blend the application UI, documents, and media content. In this series of blog entries we willl start to explore some of the improvements to data binding in WPF. You will need to have the .Net Framework 3.0, Windows Vista SDK, and Visual Studio 2005 extensions for WPF and WCF installed for this sample. For this example we will start off with a Windows Application (WPF). In the forms XMAL we will add a stack panel to hold a label and scrollbar....

posted @ Sunday, September 16, 2007 3:32 PM | Feedback (1) | Filed Under [ WPF ]

AjaxToolKit Slide Show Control

AjaxToolKit Slide Show Control While working on the Orlando Code Camp website I decided to add a page which shows a slide show of the pictures taken at code camp. The new Ajax Tool Kit Slide Show Control was perfect for this task. The photos were uploaded to the Flickr website. The Slide Show control requires a shared (static c#) function which would return an Array of Slides. The slide class contains a link to the photo, the photos name, and description of the photo. Since I did not want to store a list of photos in a database or xml file...

posted @ Sunday, September 16, 2007 3:31 PM | Feedback (1) | Filed Under [ Ajax VB ]

ScottGu at Space Coast .Net

ScottGu at Space Coast .Net Recently we had Scott Guthrie who works for Microsoft stop by and present at our meeting while he was in town for DevConnections . Scott runs the teams that build the .NET Common anguage Runtime (CLR), .NET Compact Framework, ASP.NET /Atlas, Windows Forms, Windows Presentation Foundation (aka "Avalon") , IIS 7.0, Commerce Server, Visual Web Developer, and Visual Studio Tools for Avalon (aka "Cider"). Scott did a really awsome 2 hour presentation. He started off showing the new CSS features of Visual Studio Orcas. Then he moved on to LINQ and showed some really useful examples....

posted @ Sunday, September 16, 2007 3:31 PM | Feedback (6) | Filed Under [ Events User Group ]

Vista Updates and Tools

Vista Updates and Tools First the Visual Studio 2005 SP1 update for Vista has been released. Service Pack 2 for SQL Server 2005 is out. This is the only version of SQL Server 2005 that is supported on Vista. Finally the free Virtual PC 2007 is available

posted @ Sunday, September 16, 2007 3:30 PM | Feedback (1) | Filed Under [ Vista ]

Windows WorkFlow Loop

Windows WorkFlow Loop Lets create a simple Windows Workflow that uses a loop to run some code 10 times. So first create a Visual Basic Squential Workflow Console Application. In the designer layout the workflow to look like this. Double click on the codeActivity and add the following code Public class Workflow1     Inherits SequentialWorkflowActivity     Public intLoop As Integer = 0     Private Sub codeActivity1_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)         intLoop += 1         Console.WriteLine("Loop has run " & intLoop.ToString & " times")     End Sub End Class When you open the Rule Condition Editor it is interesting to note the conditon...

posted @ Sunday, September 16, 2007 3:29 PM | Feedback (1) | Filed Under [ WorkFlow ]

SMO: Connect to Remote Server

SMO: Connect to Remote Server Here is a simple example on connecting to a Remote SQL Server with the SMO class. In this example I use a secure string for the password.         Dim srv1 As New Server("ServerName")         srv1.ConnectionContext.LoginSecure = False         srv1.ConnectionContext.SecurePassword = GetSecureString("Password")         srv1.ConnectionContext.Login = "UserName"   Function GetSecureString(ByVal str As String) As Security.SecureString         Dim ss As New System.Security.SecureString         For Each c As Char In str.ToCharArray             ss.AppendChar(c)         Next         ' prevent changes         ss.MakeReadOnly()         Return ss     End Function

posted @ Sunday, September 16, 2007 3:29 PM | Feedback (1) | Filed Under [ Sql VB ]

TableAdapter: Use a transaction with an TableAdapter

TableAdapter: Use a transaction with an TableAdapter The easiest way to use an transaction with a TableAdapter is to use an TransactionScope.  First create a TransActionScope, update the database and finally commit the transaction.  Note not all database type work with System.Transactions. Add a reference to System.Transaction for this example.          Using tc As New TransactionScope             Try                 EmployeeTableAdapter.Update(PubsDataSet.employee)                 'complete the transaction if there were no errors                 tc.Complete()             Catch                 'something went wrong let the transaction roll back             End Try         End Using

posted @ Sunday, September 16, 2007 3:28 PM | Feedback (1) | Filed Under [ Ado.Net ]

Get XML string into a DataGridView

Get XML string into a DataGridView In the msdn forums I see people asking how do they get a string that contains xml to display in the DataGridView. They way to do this is to read the string into a StringReader and use the DataSet,Readxml method to convert the xml into a datatable. Note the xml must be well formed for this to work.  Dim srXML As New IO.StringReader(strXML)  Dim dsXML As New DataSet  dsXML.ReadXml(srXML)  DataGridView1.DataSource = dsXML.Tables(0)

posted @ Sunday, September 16, 2007 3:28 PM | Feedback (0) | Filed Under [ DataGridView VB ]

Nested GridViews

Nested GridViews In this example we are going to display the orders and its details from the Northwind database in one GridView.  In an TemplateField place a GridView which calls a function to get the child records. The Web Page   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title>Untitled Page</title> </head> <body>     <form id="form1" runat="server">         <div>             <asp:GridView ID="GridView1" runat="server" CellPadding="4" GridLines="None"                 AutoGenerateColumns="False" ForeColor="#333333">                 <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />                 <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />                 <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />                 <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />                 <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />                 <AlternatingRowStyle BackColor="White" ForeColor="#284775" />                 <Columns>                     <asp:BoundField DataField="OrderId" HeaderText="Order ID" />                    ...

posted @ Sunday, September 16, 2007 3:27 PM | Feedback (0) | Filed Under [ Asp VB ]

List Vista RSS feeds

List Vista RSS feeds To list the RSS feeds added to IE7 in windows Vista add a reference to Microsoft.Feeds 1.0. You will find it in the com tab.  Imports Microsoft.Feeds.Interop Public Class Form1     Dim mgr As New FeedsManager     Dim fldr As IFeedFolder     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         fldr = mgr.RootFolder         ListFeeds(fldr)     End Sub     Private Sub ListFeeds(ByVal fldr As IFeedFolder)         For Each feed As IFeed In fldr.Feeds             Trace.WriteLine(feed.Name)             ListItems(feed)         Next         For Each f As IFeedFolder In fldr.Subfolders             Trace.WriteLine(f.Name)             ListItems(f)         Next     End Sub     Private Sub ListItems(ByVal feed As IFeed)         Trace.Indent()         For Each...

posted @ Sunday, September 16, 2007 3:27 PM | Feedback (1) | Filed Under [ VB Vista ]

Vista: File System Transactions

Vista: File System Transactions Windows Vista has several new functions for using transactions when working with files.  Here is an example on how to create a transaction, work with some files, and commit it. Imports System.Runtime.InteropServices Imports Microsoft.Win32.SafeHandles Imports System.IO Module Module1     Public Declare Auto Function CreateTransaction Lib "Ktmw32.dll" (ByVal Attributes As IntPtr, _         ByVal guid As IntPtr, ByVal options As Integer, ByVal isolationlevel As Integer, _         ByVal isolationflags As Integer, ByVal milliseconds As Integer, ByVal description As String) As IntPtr     Public Declare Auto Function RollbackTransaction Lib "Ktmw32.dll" (ByVal handle As IntPtr) As Boolean     Public Declare Auto Function CommitTransaction Lib "Ktmw32.dll" (ByVal handle As IntPtr) As Boolean     Public Declare...

posted @ Sunday, September 16, 2007 3:25 PM | Feedback (1) | Filed Under [ VB Vista ]

Draw an Icon in a DataGridViewButtonCell

Draw an Icon in a DataGridViewButtonCell Here is a simple example on how to draw in a DataGridViewButtonCell. In this example an icon is displayed when button is pushed and the icon is made invisible when its pushed again. I am storing the if the button has been pressed in the cell's tag. I use the cellPainting event to draw the icon when needed. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Text; using System.Windows.Forms; namespace CSButtonColumn {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void Form1_Load(object sender, EventArgs e)         {             String strConn = "Server = .\\SqlExpress;Database =...

posted @ Sunday, September 16, 2007 3:25 PM | Feedback (1) | Filed Under [ C# DataGridView ]

I've been Tagged: Five Things You Might Not Know About Me

I've been Tagged: Five Things You Might Not Know About Me I have been tagged by Shawn Weisfeld. Here are 5 things you might not know about me. 1) My son Ryan, brother Denis and I are all Eagle Scouts 2) I love to go camping. I have a lot of good memories backpacking upstate New York. 3) My current job is an assistant engineer onboard Sun Cruz's Surfside Princess 4) I have 4 dogs, 4 cats, and 3 birds as pets. 5) While working on ships I have visited England, Scottland, Ireland, Germany, Norway, Spain, Canada, Puerto Rico, UAE, and Bahrain.

posted @ Sunday, September 16, 2007 3:24 PM | Feedback (1) | Filed Under [ Archive ]

SQLCLR: Create a custom function

SQLCLR: Create a custom function I store a persons full name in the name field of one my sql express database which I wanted to sort by the last name.  Well I could always try a query like this. SELECT * FROM SPEAKERS ORDER BY SUBSTRING(NAME, PATINDEX('%  %', NAME), LEN(NAME) + 1 - PATINDEX('%  %', NAME)) Unfortuntely some of the names have a middle initial so this method was not fool proof.  This is where SQLCLR came to the rescue.  By creating a SQL Server Project you can create functions with VB.Net code.  So lets create a Sql Server Project and right click on the Project Name...

posted @ Sunday, September 16, 2007 3:24 PM | Feedback (1) | Filed Under [ Sql ]

Inner Join with 2 or more tables

Inner Join with 2 or more tables If you are getting data from more than 2 tables you need to surround the inner joins in brackets. For this example I am using the just released SQL Compact Edition. You will find a sample NorthWind database in the sdk. Note to work with a SQL CE database you need to add a reference to the System.Data.Sqlce.dll you find in the directory you installed sql server ce. Imports System.Data.SqlServerCe Imports System.Text   Public Class Form1     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Dim conn As New SqlCeConnection("data source='NorthWind.sdf'; mode=Exclusive;")         Dim...

posted @ Sunday, September 16, 2007 3:23 PM | Feedback (1) | Filed Under [ Ado.Net VB ]

Unable to Update Database added to Project

Unable to Update Database added to Project I see from time to time people complaining they can not update an database they added to their Visual Studio 2005 project. Sometimes your database is actually getting updated but Visual Studio is copying the old version of the database over the updated version. You should check and make sure the Database's Copy to Output property is not set to Copy Always. It should be set to Copy if newer.

posted @ Sunday, September 16, 2007 3:22 PM | Feedback (3) | Filed Under [ Ado.Net ]

Vista Application Recovery

Vista Application Recovery Ever want to add the ability to recover the user data if your application has crashed. Windows Vista has some nice apis to make this easy. The RegisterApplicationRestart api tells Vista we would like the app to restart if it crashes or hangs. This api takes two arguments a string which will be the command line argument when the application restarts and RestartFlags. For this example we will tell the app to always restart. Note the app must run 60 seconds before it will restart.     Enum RestartFlags         Always = 0         Cyclical = 1         NotifySolution = 2         NotifyFault...

posted @ Sunday, September 16, 2007 3:22 PM | Feedback (1) | Filed Under [ VB Vista ]

UpdatePanel Gotcha

UpdatePanel Gotcha Do not update the contents inside a UpdatePanel with java script. You will not get the resuts you expect. For example place a span and button inside an update panel.When you click on a button control the java script onClientClick will fire followed by the Click event for the button. So if we update the span's text with onClientClick the text will update briefly then the UpdatePanel will catch the post back made by the click event and erase our changes. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <%@ Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"     Namespace="Microsoft.Web.UI" TagPrefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD...

posted @ Sunday, September 16, 2007 3:18 PM | Feedback (1) | Filed Under [ Ajax ]

Datagrid Validation

Datagrid Validation The DataGridView has a CellValidating Event to validate the data entered. Here is how to do it with the DataGrid. There are 2 method to do this. My method is to add a tablestyle to the datagrid. For the cells I want to validate I handle the DataGridTextBoxColumn's Textbox's Validate event. George Shepherd's method is use the CurrentCellChanged event. You can read about this method in the Windows Forms FAQ. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Text; using System.Windows.Forms; namespace CSDatagrid {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void Form1_Load(object sender, EventArgs e)         {            ...

posted @ Sunday, September 16, 2007 3:05 PM | Feedback (2) | Filed Under [ C# DataGrid ]

Printer Compatibility Library 1.0

Printer Compatibility Library 1.0 Visual Basic 6.0 and earlier had a printer object which made it simple to print. The Printer Compatibility Library 1.0 makes it possible to use the same object with VB or C# 2005. After installing the Power Pack just add a reference to Microsoft.VisualBasic.PowerPacks.Printing.Printer   VB Sample Imports Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 Public Class Form1     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Dim p As New Printer         p.Print("Page 1")         p.NewPage()         p.Print("Page 2")         p.EndDoc()     End Sub End Class   C# Sample using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6; namespace PrinterCS {     public partial class Form1 : Form     {         public Form1()         {            ...

posted @ Sunday, September 16, 2007 3:04 PM | Feedback (1) | Filed Under [ C# General VB ]

Data From Multiple Tables in a DataGridView

Data From Multiple Tables in a DataGridView There is Msdn Knowledge base article which shows how to create a JoinView class. The JoinView class is for joining 2 tables together for data binding. Basically you load 2 or more tables into a dataset and set up some data relations for the related tables. When you create the Joinview the first argument is the main table, 2nd is a list of fields you want to show, 3rd is a filter, and 4th is the field to sort on. The last 2 arguments are option. Since the article includes a vb sample I...

posted @ Sunday, September 16, 2007 3:02 PM | Feedback (1) | Filed Under [ C# DataGridView ]

WPF: DataBind a ListView

WPF: DataBind a ListView There is not a DataGrid or DataGridView in Windows Presentation Foundation.  Use the ListView to display data in a table.  In the window's Xaml define the listview and the fields you want displayed.  The code behind file is where you get the data from the Northwind database and bind the listview. The Windows Xaml <Window x:Class="Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="WPF1" Height="300" Width="300"     >   <Grid>     <ListView Margin="25,22,30,48" Name="ListView1" >       <ListView.View>         <GridView >           <GridViewColumn Header ="Last Name" DisplayMemberBinding="{Binding LastName}" Width="100"></GridViewColumn>           <GridViewColumn Header ="First Name" DisplayMemberBinding="{Binding FirstName}" Width="100"></GridViewColumn>         </GridView>       </ListView.View>     </ListView>   </Grid> </Window> The Code Behind Imports System.Data ' Interaction logic for Window1.xaml Partial Public Class Window1     Inherits System.Windows.Window     Public Sub...

posted @ Sunday, September 16, 2007 3:01 PM | Feedback (1) | Filed Under [ WPF ]

AutoComplete in DataGridView

AutoComplete in DataGridView In the datagridview's editing control showing event you have better access to the textboxes properties. Here is an example of adding autocomplete to the textbox. VB Sample Imports System.Data.SqlClient Public Class Form1     Dim scAutoComplete As New AutoCompleteStringCollection     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Dim strConn As String         Dim da As SqlDataAdapter         Dim conn As SqlConnection         Dim ds As New DataSet         strConn = "Server = .;Database = NorthWind; Integrated Security = SSPI;"         conn = New SqlConnection(strConn)         da = New SqlDataAdapter("Select * from [Orders]", conn)         da.Fill(ds, "Orders")         DataGridView1.DataSource = ds.Tables("Orders")         Dim cmd As New SqlCommand("Select...

posted @ Sunday, September 16, 2007 3:00 PM | Feedback (3) | Filed Under [ C# DataGridView VB ]

.Net Framework 3.0 Text to Speech

.Net Framework 3.0 Text to Speech The dot net framework 3.0 now has a managed provider for text to speech. I tested this app on a machine with windows xp service pack 2 and the Dot Net FrameWork 3.0 RC1. The link is to set up instructions for the .net framework 3.0   For this sample add a reference to system.speech, place a textbox named txtSay, a button named btnSay, and listbox named lstVoice. The application fills a list box with the installed voices on the system at startup. When you click on the button it says the text in the textbox...

posted @ Sunday, September 16, 2007 2:57 PM | Feedback (1) | Filed Under [ C# General VB ]

Beta Certification Exam

Beta Certification Exam I took the beta exam for Microsoft Windows Mobile 5.0 - Application Development (exam number 70-540) with the visual basic option. The exam had 81 questions with a 4 hour time limit. There was one c# question slipped in there. There were questions on the creating menus, smart phone connection status to the network, interacting with contact list, listing items in the task list, serial port, xml, and httpwebrequests. SQL Everywhere (formerly SQL Mobile) was a topic which had a few questions. You will need to know how to repair a database, and sync with a sql 2005 database....

posted @ Sunday, September 16, 2007 2:55 PM | Feedback (1) | Filed Under [ Archive General ]

Secure Strings

Secure Strings The SecureString is a new class that was added in the .Net framework 2.0 which allows you to store info in memory securely. The SecureString could be used to safely secure a password or credit number. The example shows how to add info to the string, prevent changes from being make to the data, and finally how to get the info back. I included c# and VB samples. C# sample using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Security; using System.Runtime.InteropServices; namespace SecureStringCS {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void Form1_Load(object sender, EventArgs e)        ...

posted @ Sunday, September 16, 2007 2:54 PM | Feedback (1) | Filed Under [ C# General VB ]

Predicates

Predicates I recently read an article in the MSDN magazine about Predicates and Actions written by Ken Getz. I was thinking that predicates will make it easy to create a master details datagridview for a business object. This example creates 2 classes Customers and Orders. I used the Northwind database to fill a list of customers and a list of orders. I bound one grid to a binding source who's datasource is the list of customers. In the binding sources position changed event I use the list of orders findall method to show all the orders for a customer. The classes...

posted @ Sunday, September 16, 2007 2:52 PM | Feedback (1) | Filed Under [ DataGridView Generics VB ]

Create a Pivot Table

Create a Pivot Table Here is a quick example on how to rotate or pivot the data in a datagridview. This is a c# program which creates a new data table with a rotated version of the data to bind to. There is a VB version on the vb-tips website. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Pivot {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         DataTable dt1;         private void Form1_Load(object sender, EventArgs e)         {             dt1 = CreateTable();             DataTable dt2 = new DataTable("Reflected");             for (int i = 0; i < dt1.Rows.Count; i++)             {                 dt2.Columns.Add(i.ToString());            ...

posted @ Sunday, September 16, 2007 2:49 PM | Feedback (1) | Filed Under [ C# DataGridView ]

Use LogParser with VB.Net

Use LogParser with VB.Net There are times I would like to get information from the log files of a website and display them on a web form or windows form. I created a simple sample which uses the logparser dll. I added a reference to logparser.dll in the program files\log parser 2.2 folder. You can download log parser here. Imports MSUtil Public Class Form1     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Dim dt As DataTable = parseLog("select c-ip, count(c-ip) as visits from c:\W3SVC525089654\ex*.log where cs-uri-stem like '%.aspx' group by c-ip order by visits desc")         DataGridView1.DataSource = dt        ...

posted @ Sunday, September 16, 2007 2:45 PM | Feedback (1) | Filed Under [ VB ]

DataGridView Grouping

DataGridView Grouping Several people in the msdn forums have asked how to make groupings more noticable in the datagridview. Here is my solution Imports System.Data.SqlClient Public Class Form1     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Dim dt As New DataTable         Dim strConn As String         Dim da As SqlDataAdapter         Dim conn As SqlConnection         strConn = "Server = .;Database = NorthWind; Integrated Security = SSPI;"         conn = New SqlConnection(strConn)         da = New SqlDataAdapter("Select CategoryID, ProductName, UnitPrice from Products Order By CategoryID", conn)         da.Fill(dt)         dt.Columns("CategoryID").DefaultValue = 6         DataGridView1.DataSource = dt         DataGridView1.Rows(0).DefaultCellStyle.BackColor = Color.SkyBlue     End Sub     Private Sub DataGridView1_CellFormatting(ByVal sender...

posted @ Sunday, September 16, 2007 2:44 PM | Feedback (2) | Filed Under [ DataGridView VB ]

Extend the Table Adapter

Extend the Table Adapter The table adapter is missing some events and properties that the data adapter has. Fortunately the tableadapter class is a partial class that uses a data adapter. This makes it easy to add properties or events to it. For this example I opened the data sources window and created a data source to the Adventure Works Employees table. I dropped the table on a form. The dataset is named AdventureWorksDataSet and the table adapter is EmployeeTableAdapter. The table adapter is in the DataSetNameTableAdapters name space. For our example it is AdventureWorksDataSetTableAdapters. The table adapter class has a...

posted @ Sunday, September 16, 2007 2:43 PM | Feedback (1) | Filed Under [ DataGridView VB ]

Make a Datagridview move to the next cell on Enter

Make a Datagridview move to the next cell on Enter To make a datagridview move to the next column when you press the enter you need to create a new control which inherits from datagridview. In the new control override PreProcessMessage to prevent the default enter key behavior. I also created a new column which converts an enter press to a tab key. Here is a simple c# example. A VB 2005 example is available on the VB-Tips website. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Text; using System.Windows.Forms; namespace EnterNextCell {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }        ...

posted @ Sunday, September 16, 2007 2:42 PM | Feedback (1) | Filed Under [ C# DataGridView ]

DatagridView ProgressBar Column

DatagridView ProgressBar Column Here is a c# example on how to create a progress bar column for the datagridview. You can find a VB example on the VB-Tips website. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace csProgressBarColumn {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void Form1_Load(object sender, EventArgs e)         {             ProgressColumn col = new ProgressColumn();             dataGridView1.Columns.Add(col);             dataGridView1.AllowUserToAddRows = false;             dataGridView1.RowCount = 5;             int x = 1;             foreach (DataGridViewRow row in this.dataGridView1.Rows)             {                 row.Cells[0].Value = x*20;                 x++;             }         }     } } public class ProgressColumn : DataGridViewColumn {     public ProgressColumn():base(new ProgressCell())     {     }     public override DataGridViewCell CellTemplate     {         get        ...

posted @ Sunday, September 16, 2007 2:41 PM | Feedback (1) | Filed Under [ C# DataGridView ]

Encrypting Data

Encrypting Data Here is a vb2005 example on how to encrypt and decrypt data. I am storing the encryption key as a base64 string in the programs settings. The settings name is Key and its starting string value was Unknown. In a production application I would store it in a more secure location. Imports System.Security.Cryptography Imports System.IO Imports System.Text Public Class Form1     Public Key() As Byte     Public IV() As Byte     Public Function Encrypt(ByVal strData As String) As Byte()         Dim data() As Byte = ASCIIEncoding.ASCII.GetBytes(strData)         Dim tdes As TripleDESCryptoServiceProvider = _                 New TripleDESCryptoServiceProvider         If Key Is Nothing Then             tdes.GenerateKey()             tdes.GenerateIV()             Key = tdes.Key             IV =...

posted @ Sunday, September 16, 2007 2:39 PM | Feedback (1) | Filed Under [ General VB ]

Tampa Code Camp

Tampa Code Camp I did a session at the Tampa code camp on the datagridview. I covered sorting, changing column types, cell format event, sql dependency, and exporting to spread sheets. Download the powerpoint and sample code.

posted @ Sunday, September 16, 2007 2:38 PM | Feedback (1) | Filed Under [ Camp DataGridView ]

Get the right row from a sorted DataGridView

Get the right row from a sorted DataGridView When a datagridview is bound to a datatable you need to use the datatable's defautview to find the right record after the grid has been sorted. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Diagnostics; namespace CsharpRow {     public partial class Form1 : Form     {         DataTable dt;         public Form1()         {             InitializeComponent();         }         private void Form1_Load(object sender, EventArgs e)         {             String strConn = "Server = .;Database = NorthWind; Integrated Security = SSPI;";             SqlConnection conn = new SqlConnection(strConn);             SqlDataAdapter da = new SqlDataAdapter("Select * from Products", conn);             dt = new DataTable();             da.Fill(dt);             dataGridView1.DataSource=dt;         }         private void...

posted @ Sunday, September 16, 2007 2:38 PM | Feedback (1) | Filed Under [ C# DataGridView ]

Binding a Datagridview and binding navigator with code

Binding a Datagridview and binding navigator with code Here is a c# example on how to bind a datagridview and bindingnavigator with code. I manually added the save button to the bindingnavigator. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace CSharpBindingSource {     public partial class Form1 : Form     {         SqlDataAdapter da;         SqlConnection conn;         DataSet ds;         BindingSource bs;         public Form1()         {             InitializeComponent();         }         private void Form1_Load(object sender, EventArgs e)         {             String strConn = "Server = .;Database = NorthWind;Integrated Security = SSPI;";             conn = new SqlConnection(strConn);             da = new SqlDataAdapter("Select * From Employees", conn);             SqlCommandBuilder cmd = new SqlCommandBuilder(da);            ...

posted @ Sunday, September 16, 2007 2:37 PM | Feedback (1) | Filed Under [ C# DataGridView ]

Tallahassee Code Camp

Tallahassee Code Camp I did a session on the DataGridView and DLinq at the Tallahassee code camp today. You can find the power point slides and sample code at the vb-tips website's new code camp section.

posted @ Sunday, September 16, 2007 2:36 PM | Feedback (1) | Filed Under [ Camp ]

Atlas Tool Kit

Atlas Tool Kit The atlas tool kit is truely awsome. I see there is an error in collapsiblepanelextender documentation. The sample code on the webpage shows the expanddirection as height when the valid values are horizontal and vertical. It also shows openedsize instead of expandedsize.              <atlasToolkit:CollapsiblePanelExtender ID="cpe" runat="Server">                 <atlasToolkit:CollapsiblePanelProperties ExpandedSize="200" TargetControlID="pnlRss"                     ExpandControlID="LinkButton1" CollapseControlID="LinkButton1" Collapsed="True"                     TextLabelID="LinkButton1" CollapsedText="Show Details..." ExpandedText="Hide Details..."                     SuppressPostBack="true" />            </atlasToolkit:CollapsiblePanelExtender>            <asp:Label ID="lblRss" Text="Whats New in VB-Tips" runat="server"></asp:Label> <asp:LinkButton ID="LinkButton1" runat="server" Text="Show Details.."> </asp:LinkButton>                 <asp:Panel ID="pnlRss" runat="server" Width="100%" ScrollBars="Vertical">                 <asp:DataList ID="DataList1" runat="server" BackColor="White" BorderColor="#E7E7FF"                     BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="RssDataSource1"                     GridLines="Horizontal">                     <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />                     <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />                     <ItemTemplate>                          <asp:HyperLink...

posted @ Sunday, September 16, 2007 2:35 PM | Feedback (1) | Filed Under [ Ajax ]

DXCore

DXCore Developers express has a free product DX Core. It is a framework to develop add ins for visual studio. With it you can paint on the ide, work with the text, etc. I answer alot of questions in the newsgroups and forums. From time to time I copy code from the ide and when it pasted it looses the format. To overcome this limitation I usually paste the text in notepad. I then recopy the text and paste it in the question I am answering to preseve the format. Today I used the dxcore to add the copy as text...

posted @ Sunday, September 16, 2007 2:34 PM | Feedback (2) | Filed Under [ DXCore General ]

Find Duplicate Records in a Datatable

Find Duplicate Records in a Datatable I was asked how to find duplicate records in a datatable, I used a dataview to sort my records. I used the sorted list to check the next record for a duplicate record. The duplicate will be deleted. Imports System.Security.Cryptography Public Class Form1     Dim dt As New DataTable     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         dt.Columns.Add("Name")         dt.Columns.Add("Number", GetType(Integer))         For x As Integer = 0 To 200             Select Case x Mod 3                 Case 0                     dt.LoadDataRow(New Object() {"Ken", TrueRandom.Rand(100)}, True)                 Case 1                     dt.LoadDataRow(New Object() {"Kelly", TrueRandom.Rand(100)}, True)                 Case 2                     dt.LoadDataRow(New Object() {"Bill", TrueRandom.Rand(100)},...

posted @ Sunday, September 16, 2007 2:32 PM | Feedback (2) | Filed Under [ Ado.Net ]

SQL Server 2005 SP 1 help

SQL Server 2005 SP 1 help From my partner Kelly Martins at KJM Solutions If this error occurs here is what worked for me. I hope it may work for you but am not sure. In my case I had SQL Express 2005 Installer on my system as well as I run both (one for development, one for production). Shut down all SQL related services manually. I set registry permissions on Software\Policies\Microsoft\Windows\Installer to include the account that is doing the install with Full Control. Click Advanced and make sure everything is selected. I downloaded and ran the SQL Install Cleanup and...

posted @ Sunday, September 16, 2007 2:31 PM | Feedback (1) | Filed Under [ Sql ]

Virtual Server 2005 R2 Now free

Virtual Server 2005 R2 Now free Microsoft has now made Virtual server 2005 R2 a free product. You can download Virtual Server 2005 R2 here.

posted @ Sunday, September 16, 2007 2:30 PM | Feedback (1) | Filed Under [ General ]

Tom Fuller MVP

Tom Fuller MVP Congradulations to my friend Tom Fuller on making Solution Architect MVP. Tom runs the Soa Pitstop website. Tom also speaks at florida code camps and user group meetings.

posted @ Sunday, September 16, 2007 2:30 PM | Feedback (1) | Filed Under [ Archive ]

SQL Everywhere

SQL Everywhere Microsoft will be removing the restrictions on sql sever 2005 mobile edition so it works in a desktop environment. Check out the SQL everywhere FAQ on Steve Lasker's blog

posted @ Sunday, September 16, 2007 2:29 PM | Feedback (1) | Filed Under [ General Sql ]

VB 2005 Performance issues Hotfix

VB 2005 Performance issues Hotfix A hot fix that addresses some performance issues with Visual Basic 2005 has been released.If you are having the problems listed in the KB article call PSS (Product Support Services) 800-936-4900 and tell Technical Routers that they want to be transferred to Developer Support, Visual Basic team, it would expedite the call. Request the hot fix described in KB Article 917452. The KB article is not available yet.

posted @ Sunday, September 16, 2007 2:29 PM | Feedback (1) | Filed Under [ VB ]

Atlas April Ctp Released

Atlas April Ctp Released The April CTP of Atlas was released today. Along with a toolkit that has some cool tools.

posted @ Sunday, September 16, 2007 2:28 PM | Feedback (1) | Filed Under [ Ajax ]

Web Control Issue

Web Control Issue I was playing around with creating a web control you can add to the toolbox. To create this I started with a VB 2005 class library project. I added a reference to the system.web. I added a bitmap to the project and set its build action to embedded resource. I also set the tagprefix for the control. Here is the issue. If I set the namespace in the project properties everything works as expected. If set the namespace the toolbox bitmap and tag prefix do not work . Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Drawing <Assembly: System.Web.UI.TagPrefix("MyControls", "kens")> <ToolboxBitmap(GetType(MyWeatherSticker), "Arrow.bmp")> _ <ToolboxData("<{0}:MyWeatherSticker...

posted @ Sunday, September 16, 2007 2:27 PM | Feedback (1) | Filed Under [ VB ]

More WMI events

More WMI events I was playing around with using the wmi _InstanceModificationEvent. I created a sample which will keep an acurate list of the screen size. Like all wmi programs you need to add a reference to system.management for this to work. My sample requires a listbox on a form. Imports System.Management Public Class Form1     Dim WithEvents w As ManagementEventWatcher     Dim q As WqlEventQuery     Delegate Sub LoadList()     Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing         w.Stop()     End Sub     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Try             q = New WqlEventQuery             q.QueryString = "SELECT...

posted @ Sunday, September 16, 2007 2:09 PM | Feedback (1) | Filed Under [ WMI ]

Dynamic Help Window in VB Express

Dynamic Help Window in VB Express The Dynamic Help window is not supported in visual basic express.

posted @ Sunday, September 16, 2007 2:08 PM | Feedback (1) | Filed Under [ VB ]

Dot Net User Group

Dot Net User Group My local computer club SCTPA folded today. I am trying to start a dot net user group in Brevard county Florida. Any one interested in joining should send me an email.

posted @ Sunday, September 16, 2007 2:07 PM | Feedback (1) | Filed Under [ User Group ]

Sql Server 2005 Service Pack 1

Sql Server 2005 Service Pack 1 I see there is a CTP for a Sql Server 2005 service pack available. Here is a link for anyone interested.

posted @ Sunday, September 16, 2007 2:07 PM | Feedback (1) | Filed Under [ Sql ]

Atlas March Ctp Released

Atlas March Ctp Released The March CTP of Atlas was released today. It is the first version of Atlas to have a go live license.

posted @ Sunday, September 16, 2007 2:06 PM | Feedback (1) | Filed Under [ Ajax ]

Custom Sort of DataGridView

Custom Sort of DataGridView Someone asked me about doing a custom sort on a datagridview during my datagridview session at code camp. Unfortunately this will not work if the datagridview is bound to a datasource. This example numbers as string data to a datagridview. When you sort this column the values will not be in numeric order. This example converts the string to a number and sorts based on the number. Public Class Form1     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         DataGridView1.ColumnCount = 1         DataGridView1.Columns(0).HeaderText = "String"         For x As Integer = 0 To 100             DataGridView1.Rows.Add(New...

posted @ Sunday, September 16, 2007 2:06 PM | Feedback (6) | Filed Under [ DataGridView ]

Async DataGridView fill Issue

Async DataGridView fill Issue Here is an issue brought up by fellow MVP Jose Fuentes. When filling a data table asyncronously bound to a datagridview you will wind up with a blank line in the datagridview. To get around this issue do not set the datasource until the data table is filled. Public Class Form1     Dim dt As New DataTable     Delegate Sub ReloadGrid(ByVal dt As DataTable)     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         dt.Columns.Add("Column1")         dt.Columns.Add("Column2")         ' comment out the next line to load grid properly         DataGridView1.DataSource = dt         Me.FillDALViaThread(dt, Me)     End Sub     Public Sub FillDALViaThread(ByRef DT...

posted @ Sunday, September 16, 2007 2:05 PM | Feedback (1) | Filed Under [ DataGridView ]

New Website

New Website Upgraded the website today to use the asp.net 2.0. I used the small business template from the asp.net website for the site look. Posted it on the KJM Solutions server. I am using SQL Server 2005 for the blog now. We are getting closer to opening up for business.

posted @ Sunday, September 16, 2007 2:04 PM | Feedback (1) | Filed Under [ Archive ]

Restore SQL 2005 Database

Restore SQL 2005 Database You can use the smo restore class to restore a sql server 2005 database. SqlExpress databases must be restored from the sql express directory. This sample restores the northwind database backed up in my last blog entry. You need to add a reference to Microsoft.SQLServer.SMO for this sample to work. Using SMO with Sql Express Imports Microsoft.SqlServer.Management.Smo Module Module1     Sub Main()         Dim svr As Server = New Server(".\SQLEXPRESS")         Dim rst As Restore = New Restore         Dim strPath As String = svr.Information.MasterDBPath         strPath = strPath.Replace("\DATA", "\Backup\Nwnd.Bak")         rst.Devices.Add(New BackupDeviceItem(strPath, DeviceType.File))         rst.Database = "Northwind"         rst.ReplaceDatabase = True         Try             rst.SqlRestore(svr)        ...

posted @ Sunday, September 16, 2007 2:03 PM | Feedback (1) | Filed Under [ Sql VB ]

Backup SQL 2005 Database

Backup SQL 2005 Database You can use the smo backup class to backup a sql server 2005 database. SqlExpress databases must be backed up to the sql express directory. You need to add a reference to Microsoft.SQLServer.SMO for this sample to work. Using SMO with Sql Express Imports Microsoft.SqlServer.Management.Smo Module Module1     Sub Main()         Dim svr As Server = New Server(".\SQLEXPRESS")         Dim bkp As Backup = New Backup()         Dim strPath As String = svr.Information.MasterDBPath         strPath = strPath.Replace("\DATA", "\Backup\Nwnd.Bak")         bkp.Action = BackupActionType.Database         bkp.Database = "NorthWind"         Dim bdi As New BackupDeviceItem(strPath, DeviceType.File)         bkp.Devices.Add(bdi)         Try             bkp.SqlBackup(svr)         Catch ex As Exception             MsgBox(ex.ToString)         End Try     End Sub End Module Module...

posted @ Sunday, September 16, 2007 2:03 PM | Feedback (1) | Filed Under [ Sql VB ]

Real Random Numbers

Real Random Numbers The random function does not generate truely random numbers. Use the RNGCyptoServiceProvider to create them Imports System.Security.Cryptography Public Class Form1     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         FillList()     End Sub     Private Sub FillList()         ListBox1.Items.Clear()         For x As Integer = 0 To 20             ListBox1.Items.Add(TrueRandom.Rand(500).ToString)         Next     End Sub     Private Sub btnNewList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewList.Click         FillList()     End Sub End Class Public Class TrueRandom     Public Shared Function Rand(ByVal MaxNum As Integer) As Integer         Dim rnd(20) As Byte         Dim num As Long         Dim generator As New RNGCryptoServiceProvider         generator.GetBytes(rnd)         For x As Integer = 0 To...

posted @ Sunday, September 16, 2007 2:01 PM | Feedback (1) | Filed Under [ Archive VB ]

VB 2005 Complier Hotfix

VB 2005 Complier Hotfix There was a hot fix released for the VB 2005 complier problem described here. If you are having the problems listed call PSS (Product Support Services) 800-936-4900 and tell Technical Routers that they want to be transferred to Developer Support, Visual Basic team, it would expedite the call. Ask about getting the patch for KB# 915038.

posted @ Sunday, September 16, 2007 2:00 PM | Feedback (2) | Filed Under [ VB ]

USB drive insert notification

USB drive insert notification The wmi supports events. I use the instance creation event for the Win32_LogicalDisk for the notification. Add a reference to the system.management for this sample. You need a form with a listbox for the code to work. Imports System.Management Public Class Form1     Dim WithEvents w As ManagementEventWatcher     Dim q As WqlEventQuery     Delegate Sub LoadList()     Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing         w.Stop()     End Sub     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Try             q = New WqlEventQuery             q.QueryString = "SELECT * FROM" & _                         " __InstanceCreationEvent WITHIN 1 "...

posted @ Sunday, September 16, 2007 1:59 PM | Feedback (1) | Filed Under [ WMI ]

Got Code?

Got Code? Orlando .NET CodeCamp Saturday, March 25 2006 Here is a list of the topics 3D For the Rest of Us (Avalon/WPF) 7 Ways to Ajax ASP.NET 2.0 Membership and Role Management An In-depth look at Profiles in ASP.NET 2.0 A guide to developing Web Server Controls Accessible Web Applications (Section 508) Building new apps with ATLAS - Smart Client Application Development & Deployment Customizing the Windows Forms DataGridView Generic Database Programming with ADO.NET DotNetNuke Chalk Talk / BOF Developing Custom Modules the easy way with code generation and freely available tool Introduction to the DotNetNuke portal framework (part 1) Introduction to the DotNetNuke...

posted @ Sunday, September 16, 2007 1:59 PM | Feedback (1) | Filed Under [ Camp ]

KJM Solutions

KJM Solutions KJM Solutions is now open for web hosting. We offer .NET Framework 1.1 and .NET Framework 2.0, ASP.NET, application hosting and web services hosting. 1 GB Disk Space divided among all services as you choose, 350GB Monthly Data Transfer, Unlimited POP3 Email Accounts, Unlimited Microsoft SQL Server 2005 Databases, Unlimited Microsoft SQL Server 2000 Databases, Unlimited FTP Accounts, Unlimited Email Forwards, Frontpage 2002 Extensions, 24/7 Email Support, Web Based Email for $35.00 per month. The first 3 months are free. Contact Sales for more info.

posted @ Sunday, September 16, 2007 1:58 PM | Feedback (2) | Filed Under [ Archive ]

Find Missing dll

Find Missing dll There was a question the other day in the vb.net newsgroup on how to make a list of the missing dlls on your system. Files that are registered by regsvr32 create a CLSID. This program will check all the CLSID registered dll exists and adds the missing ones to a list box. Imports Microsoft.Win32 Imports System.IO Public Class Form1     Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code "     Public Sub New()         MyBase.New()         'This call is required by the Windows Form Designer.         InitializeComponent()         'Add any initialization after the InitializeComponent() call     End Sub     'Form overrides dispose to clean up the component list.    ...

posted @ Sunday, September 16, 2007 1:58 PM | Feedback (1) | Filed Under [ Archive ]

Code Camp

Code Camp I went to the Code Camp in Tallahassee and did a session on Windows Forms Datagrid. I talked about the new features in VS.Net 2005 and customizing the datagrid. You can find the most of the code on my Datagrid help website. If you have any questions please feel free to email me.

posted @ Sunday, September 16, 2007 1:56 PM | Feedback (1) | Filed Under [ Camp ]

Blog up and running

Blog up and running Well I got my blog up and running today. I am using a MySql database for storing the data. My web host brinkster offers Sql Server, MS Access, and MySql database storage. I seam to get a lot of data access errors using MS Access on the web when I have too many users at once. I figured I will try the MySql. Seams to be a very powerfull database full of features. I still prefer to use Sql Server. In addition to this site I also maintain a VB.Net and VB-Tips website with Cor Ligthert. I am...

posted @ Sunday, September 16, 2007 1:56 PM | Feedback (1) | Filed Under [ Archive ]

Image Buttons

Image Buttons I have been working on making image buttons that change color when the mouse is over them. I have created transparent gifs using vb.net for the buttons. I use a transparent background because the image will display the background color of the image button. I change the backcolor with java script. The code I used to create the transparent gif is based on code from Bob Powells GDI+ FAQ

posted @ Sunday, September 16, 2007 1:56 PM | Feedback (1) | Filed Under [ GDI ]

Binding to a WPF Listbox Part 1

Binding to a WPF Listbox Part 1 Binding to a WPF Listbox is a lot more flexible than binding to a Windows Form listbox.  In the WPF Listbox you need to define a DataTemplate which tells the Listbox how to display the data.  For this example we will create an Animals class and display the data in a Listbox. Pages XAML <Window x:Class="Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="Window1" Height="300" Width="300">  <Window.Resources>   <DataTemplate x:Key ="lstItem" >    <StackPanel>     <Grid>      <Grid.ColumnDefinitions>       <ColumnDefinition Width="75" />       <ColumnDefinition Width="75" />      </Grid.ColumnDefinitions>      <TextBlock Text="{Binding Path=Animal}" Grid.Column="0" />      <TextBlock Text="{Binding Path=Species}" Grid.Column="1" />     </Grid>    </StackPanel>   </DataTemplate>  </Window.Resources>   <Grid>   <ListBox Margin="14,15,47,34" Name="ListBox1" ItemTemplate="{StaticResource lstItem}" >   </ListBox>  </Grid> </Window> The Code   Class Window1     Private Sub Window1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated        ...

posted @ Sunday, September 16, 2007 1:55 PM | Feedback (1) | Filed Under [ WPF ]

MySql Full Text searches

MySql Full Text searches You must create a table that uses the MyISAM engine to support full text searches in MySql. Here is an example on how to create the table.         conn = New MySqlConnection(strConn)         conn.Open()         Dim sbCmd As New System.Text.StringBuilder         sbCmd.Append("Create Table If Not Exists MyBlog ")         sbCmd.Append("(PostDate DateTime NOT NULL PRIMARY KEY, ")         sbCmd.Append("BlogEntry Text, FullText(BlogText))")         sbCmd.Append(" Engine = MyISAM")         cmd = New MySqlCommand(sbCmd.ToString, conn)         cmd.ExecuteNonQuery()         conn.Close() Use the MySql Match Against query to preform a full text search Match Against Query Info

posted @ Sunday, September 16, 2007 1:53 PM | Feedback (1) | Filed Under [ MySql ]

Using Linq for Master Detail in a DataGridView

Using Linq for Master Detail in a DataGridView I saw in the MSDN forums someone asking how to do a master details relationship with Linq. It is actually pretty simple. Here are the steps involved on creating the relationship. I am using VS 2008 Beta 2 for this example. Open up Visual Studio 2008 Beta 2 and create a windows forms Application Add a new Linq 2 Sql classes to the project named Northwind.dbml Drag the Northwind database's Orders and Order Details table onto the surface Save the project and build it Open the data sources window and add a new object data source. Select...

posted @ Sunday, September 16, 2007 1:51 PM | Feedback (2) | Filed Under [ DataGridView Linq ]

Powered by: