Robert Chu
09-21-2006, 02:36 AM
Hello,
I met problems when I try to add items to a dropdownlist. The code is as below. But there is an error message: Object reference not set to an instance of an object. How can I fix it ? Thanks.
myConnection = New SqlConnection(ConfigurationSettings.AppSettings("connString"))
myConnection.Open()
myCommand = New SqlCommand(strSql,myConnection)
reader = myCommand.ExecuteReader()
Dim schemaTable As DataTable = reader.GetSchemaTable()
Dim dataRow As DataRow
For i =0 to schemaTable.Rows.Count -1
'dlMsgId.Items.add()
Response.Write(dataRow("MsgId"))
Next
I met problems when I try to add items to a dropdownlist. The code is as below. But there is an error message: Object reference not set to an instance of an object. How can I fix it ? Thanks.
myConnection = New SqlConnection(ConfigurationSettings.AppSettings("connString"))
myConnection.Open()
myCommand = New SqlCommand(strSql,myConnection)
reader = myCommand.ExecuteReader()
Dim schemaTable As DataTable = reader.GetSchemaTable()
Dim dataRow As DataRow
For i =0 to schemaTable.Rows.Count -1
'dlMsgId.Items.add()
Response.Write(dataRow("MsgId"))
Next