English 中文(简体)
vb.net - Object reference not set to an instance of Object
原标题:vb.net - Object reference not set to an instance of object

我在试图将参数用于我的ql发言时,就犯了这一错误,但是,如果使用的话,那就行得当。 我的法典如下:

Dim i As String
Dim sql as String

 sql = "SELECT * FROM tblStaff WHERE Username = @User AND Password = @Pass"
 myCommand = New SqlCommand(sql, myConnection)
 myCommand.Parameters.AddWithValue("@User", txtUser.Text)
 myCommand.Parameters.AddWithValue("@Pass", txtPassword.Text)

 i = myCommand.ExecuteScalar
 txtUserType.Text = i.ToString

当我就<代码>txtUserType.Text = i.ToString发表评论时,该编码便可操作。 任何想法?

最佳回答

象愤怒一样,我们只能给你一个价值。 因此,如果你只具体说明了你方言中的一栏(图象用户类型,从图象......)的话,则行踪应重新分类(如果该栏数)。

然后,它应当发挥作用。

and by the way.. you don t have to use ToString on a variable that is a string. Just use the variables name txtUserType.Text = i

问题回答

暂无回答




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签