Friday, March 23, 2012

Getting SqlDbType not declared

How do I dim SqlDbType in my code?

Dim connAsNew Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("TrainUserConnectionString").ConnectionString)

Dim cmdAsNew Data.SqlClient.SqlCommand

With cmd

.Connection = conn

.CommandType = Data.CommandType.StoredProcedure

.CommandText ="UpdateTopics

cmd.Parameters.Add("@.classificationID", SqlDBType.Int)cmd.Parameters.Add("@.TitleID", SqlDBType.Int)

conn.Open()

ForEach itemAs ListItemIn CheckBoxList1.Items

If item.SelectedThen

cmd.Parameters("@.classificationID").Value = item.Valuecmd.Parameters("@.TitleID").Value = DropDownList1.SelectedValue

cmd.ExecuteNonQuery()

EndIf

Next

conn.Close()

EndWith

EndSub

EndClass

JJ297:

How do I dim SqlDbType in my code?

SqlDBType is not an instance class so you cannot instantiate it. It is a enumeration so it just contains a list of values.

To access the SqlDbType enumeration just add the namespace System.Data to your code behind class file

No comments:

Post a Comment