Monday, March 26, 2012

StringBuilder

can anyone tell me how to declare a stringbuilder using vb in visual studio, I am trying to use a stringbuilder in the following code, but visual studio states stringbuilder is not defined.

Imports System.Data
Imports System.Data.SqlClient
Imports System.Text.StringBuilder

Public Class datagrid2
Inherits System.Web.UI.Page

Public Sub UpdateCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)

Dim sb1 As StringBuilder = New StringBuilder("")
sb1.Append("INSERT Employees (firstname, lastname, titleofcourtesy, title, country) VALUES(")
sb1.Append("@dotnet.itags.org.sFirstName, @dotnet.itags.org.sLastName, @dotnet.itags.org.sTitle, @dotnet.itags.org.sPosition, @dotnet.itags.org.sCountry)")
cmd.CommandText = sb1.ToString()Hi,

Dim sb1 As System.Text.StringBuilder = New System.Text.StringBuilder("")

HTH
Imports System.Text.StringBuilder <-- don't do this, StringBuilder is a class, not a namespace.

use:
Imports System.Text

now you can use "StringBuilder" in your code (instead of having to write the fully qualified version of it each time)
thanks guys

0 comments:

Post a Comment