Follow me on Twitter at Twitter.com/wbm
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:http://morewally.com/cs/blogs/wallym/rss.aspx
May 2005 - Posts - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, Xamarin.iOS, Xamarin.Android, and Windows Azure.

News

Visual Studio Magazine Column Personal Blog

.NET

Book Authors

Business

Family

Friends

Georgia Tech Bloggers

Personal

Archives

May 2005 - Posts

Scalability with .NET Podcast - Broadcast #2

Subscribe

Download url: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2005/11/08/podcast-2.aspx 

Pablo Castro
Article on Asynchronous ADO.NET.
Managed Data Access
Please Buy a copy of our book!

Scott Guthrie
IIS7 with Scott Guthrie

Code Samples:

BeginExecuteNonQuery

        Dim strSql As String
        Dim strCn As String = Me.gstrAsyncString
        Dim iResult As IAsyncResult
        sqlCm = New SqlCommand()
        sqlCn = New SqlConnection(strCn)
        sqlCn.Open()
        sqlCm.Connection = sqlCn
        sqlCm.CommandType = CommandType.Text
        strSql = "insert into tblAsyncExecuteNonQuery ( ClientDateEntered) values ('" & DateTime.Now.ToString() & "')"
        sqlCm.CommandText = strSql
        Me.gdtStart = GetTickCount()
        iResult = sqlCm.BeginExecuteNonQuery(New System.AsyncCallback(AddressOf ExecuteNonQueryCallback), sqlCm)

    Private Sub ExecuteNonQueryCallback(ByVal iRes As IAsyncResult)
        Dim sqlCm As SqlCommand = CType(iRes.AsyncState, SqlCommand)
        Try
            sqlCm.EndExecuteNonQuery(iRes)
            Me.gdtEnd = GetTickCount()
            Dim timeDsplay As New DisplayTimeDelegate(AddressOf DisplayTime)
            Me.Invoke(timeDsplay)

        Catch sqlExc As SqlException
            'Perform some type of operation to notify someone that an error has occurred.
            'If an exception occurs, show it to the user.
        Finally
            If sqlCn.State <> ConnectionState.Closed Then
                sqlCn.Close()
            End If
            sqlCn.Dispose()
            sqlCn = Nothing
            sqlCm.Dispose()
            sqlCm = Nothing
        End Try

    End Sub

BeginExecuteReader

        Dim strSql As String
        Dim strCn As String = gstrAsyncString
        Dim iResult As IAsyncResult
        sqlCm = New SqlCommand()
        sqlCn = New SqlConnection(strCn)
        sqlCn.Open()
        sqlCm.Connection = sqlCn
        sqlCm.CommandType = CommandType.Text
        strSql = "select count(*) from tblAsyncExecuteNonQuery"
        sqlCm.CommandText = strSql
        Me.gdtStart = GetTickCount()
        iResult = sqlCm.BeginExecuteReader(New System.AsyncCallback(AddressOf ExecuteDataReaderCallback), sqlCm, CommandBehavior.Default)

    Private Sub ExecuteDataReaderCallback(ByVal iRes As IAsyncResult)
        Dim sqlDr As SqlDataReader
        Dim sqlCm As SqlCommand = CType(iRes.AsyncState, SqlCommand)
        Try
            sqlDr = sqlCm.EndExecuteReader(iRes)
            Me.gdtEnd = GetTickCount()
            sqlDr.Read()
            Me.giNum = Convert.ToInt32(sqlDr(0))
            Dim cntDsplay As New DisplayCountDelegate(AddressOf DisplayCount)
            Me.Invoke(cntDsplay)
            sqlDr.Close()
            sqlDr.Dispose()
            sqlDr = Nothing

        Catch sqlExc As SqlException
            'Perform some type of operation to notify someone that an error has occurred.
            'If an exception occurs, show it to the user.
        Finally

           If sqlCn.State <> ConnectionState.Closed Then
                sqlCn.Close()
            End If
            sqlCn.Dispose()
            sqlCn = Nothing
            sqlCm.Dispose()
            sqlCm = Nothing
        End Try

SqlConnectionStringBuilder

        Dim sqlCn As New SqlConnection()
        Dim scsbObj As New SqlClient.SqlConnectionStringBuilder(Me.gstrSyncString)
        Try
            scsbObj.Password = Me.txtPassword.Text
            SqlConnection.ChangePassword(scsbObj.ConnectionString, Me.txtNewPassword.Text)

            scsbObj.Password = Me.txtNewPassword.Text
            sqlCn.ConnectionString = scsbObj.ConnectionString
            sqlCn.Open()
            Me.gstrSyncString = scsbObj.ConnectionString

            MsgBox("Succesful logon with a new password.")
        Catch sqlEx As SqlException
            'Do something with this error.
            MsgBox("Error: " & sqlEx.Message.ToString())
        Finally

            If sqlCn.State <> ConnectionState.Closed Then
                sqlCn.Close()
            End If
            sqlCn.Dispose()
            sqlCn = Nothing

        End Try

DataTypes:

        Dim i As Integer
        Dim strSql As String = "select * from tblTest where 1=2"
        Dim scsbObj As New SqlConnectionStringBuilder(Me.gstrSyncString)
        Dim sqlCn As New SqlConnection(scsbObj.ConnectionString)
        Dim sqlCm As New SqlCommand(strSql, sqlCn)
        Dim sqlDr As SqlDataReader
        Dim dtData As DataTable

        Try
            sqlCn.Open()
            sqlDr = sqlCm.ExecuteReader(CommandBehavior.SchemaOnly)
            dtData = sqlDr.GetSchemaTable()
            Me.dgvColumns.DataSource = dtData
            Me.dgvColumns.Visible = True

            '            sqlDr.Read()
            For i = 0 To (sqlDr.FieldCount - 1)
                MsgBox(sqlDr.GetName(i) + vbCrLf + "SqlType: " + _
                    Convert.ToString(sqlDr.GetProviderSpecificFieldType(i)) + vbCrLf + _
                    "Database Type: " + Convert.ToString(sqlDr.GetDataTypeName(i)) + vbCrLf + _
                    ".NET Type: " + Convert.ToString(sqlDr.GetFieldType(i)) + vbCrLf)
            Next
            If Not (sqlDr.IsClosed = True) Then
                sqlDr.Close()
            End If
            sqlDr.Dispose()
            sqlDr = Nothing
        Catch sqlExc As SqlException
            MsgBox("Error: " & sqlExc.Message.ToString())
        Finally
            sqlCm.Dispose()
            sqlCm = Nothing
            If sqlCn.State <> ConnectionState.Closed Then
                sqlCn.Close()
            End If
            sqlCn.Dispose()
            sqlCn = Nothing
        End Try

    End Sub

Posted: May 31 2005, 05:37 PM by Wallym | with 4 comment(s)
Filed under:
I come to bury System.Data.SqlServer, not to praise it

Guy Barrette reminded me that I had not posted this yet.

I have written some really good SqlCLR objects that I have been doing for a demo.  Having updated these CLR objects to run on the April CTP, I am now really glad that the Sql Server/ADO.NET Team removed the System.Data.SqlServer namespace and plugged all of that code into the System.Data.SqlClient namespace.  By doing this, my code now looks and smells like any other data access code that I would have in a standard data access layer in other parts of my application.  I was skeptical at the time, but I think that the change was a good move.

Wally

DSL tools for Beta 2 of VS.NET 2005 are now available
https://blogs.msdn.com/jochens/archive/2005/05/27/422753.aspx
Posted: May 29 2005, 09:21 AM by Wallym | with no comments
Filed under:
Sql Down Under podcast

Greg Low has put together and is doing the Sql Down Under podcast.  I met Greg earlier this week in Redmond.  Greg is very knowledgeable with .NET and Sql Server.  I was very impressed with him.  This podcast, is something that I will be listening to.

http://www.sqldownunder.com/

Wally

Mainsoft's Grasshopper Gives Visual Studio Developers a jump on writing Linux Apps
http://www.eweek.com/article2/0,1759,1819419,00.asp

Mainsoft Corp. Tuesday announced a program and a new tool for Visual Studio .Net developers to use their familiar tool set to write applications for Linux.

The San Jose, Calif., company announced its Visual Studio .Net for Linux Developer Program as well as its new Visual MainWin for J2EE (Java 2 Enterprise Edition) Developer Edition tool, code-named Grasshopper.

From the article, It looks like there will be two versions.  The free version works with Apache/Tomcat.  The for-pay version works with several J2EE platforms.

Wally

WTF? Apple to use Intel chips

http://news.com.com/Apple+allegedly+explores+using+Intel+chips/2100-1042_3-5716539.html?tag=nefd.top

Apple Computer has been in talks that could lead to a decision soon to use Intel chips in its Macintosh line, according to a report published Monday.

The Wall Street Journal, citing two industry executives with knowledge of recent discussions between the companies, reported that Apple will agree to use Intel chips.

Neither company would confirm the report, and an Apple representative told the Journal that the information should be characterized as "rumor and speculation."

Wally

PS. Wow, what a cool #600 entry.  Personally, my guess is that Apple might use some support chips.

Signing an Assembly in Whidbey

I have been working on some components that require signing.  One of the things that frustrated me back during .NET 1.x beta was that the option to automagically create a keyfile was removed after beta 2.  The feedback that I heard was that security is important and the ability to just randomly create a keyfile was not good practice, therefore the ability to create the keyfile was removed.  Well, I have been dinking back around with COM+ in Whidbey.  With COM+, you have to create a keyfile.  Well, the ability to create and use a key has been put back into the IDE as of Beta 2, which I think is great news.  You select your project and then its properties.  There is a tab label signing.  With that, you can either create a new keyfile or use an exisiting one.  One side genefit of this is that it appears there is no need to specify the assebly's keyfile in the attributes for the assembly.  I think that this is an improvement as I always seemed to have problems with getting the directory correct in Everrett.

Wally

Posted: May 23 2005, 08:40 AM by Wallym | with 6 comment(s)
Filed under:
Whidbey .NET IDE improvement with regards to Windows Services

Ok, so by now, it is obvious that I have started working on some Windows Services written in .NET.  :-)

As I remember, in .NET Everrett, if I manually entered the process and service installer into the the service's install class, the process and service installer would not display in the design surface.  Well, in Whidbey's VS.NET IDE, the process and service installer are displayed on the design surface after I manually entered them.  Sweet.

Wally

Posted: May 23 2005, 08:32 AM by Wallym | with no comments
Filed under:
Specifying UserId Security for a Service with Whidbey

The install routine for a Windows Service will allow you to default the service to one of four user ids.

  • LocalService.
  • LocalSystem.
  • NetworkService.
  • User.

These values are provided by the enum System.ServiceProcess.ServiceAccount.

Typically, when I write a Windows Service, I will either run it as the LocalSystem or as a User.  If you run as the LocalSystem, don't forget to set the Username and Password properties of your ServiceProcessInstaller object to null.

Wally

Posted: May 23 2005, 08:30 AM by Wallym | with no comments
Filed under:
Windows Service Startup Modes

When you startup your Windows Services that are written in .NET, you can specify three startup modes:

  • Automatic.  When the system starts up, the service will startup as if it is set to Automatic in the Services applet.
  • Manual.  When the system starts up, the service will startup as if it is set to Manual in the Services applet.
  • Disabled.    When the system starts up, the service will not startup as if the service is set in the Disabled mode in the Services applet.

These modes are provided by the enum System.ServiceProcess.ServiceStartMode.

Wally

Posted: May 23 2005, 08:30 AM by Wallym | with 3 comment(s)
Filed under:
More Posts Next page »