Click here to Skip to main content
15,392,099 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: .Net Framework Web API & Client - Empty JSON Pin
Mycroft Holmes12-Jul-22 12:08
professionalMycroft Holmes12-Jul-22 12:08 
GeneralRe: .Net Framework Web API & Client - Empty JSON Pin
Kevin Marois 202212-Jul-22 12:36
MemberKevin Marois 202212-Jul-22 12:36 
AnswerRe: .Net Framework Web API & Client - Empty JSON Pin
Richard Deeming12-Jul-22 21:44
mveRichard Deeming12-Jul-22 21:44 
GeneralRe: .Net Framework Web API & Client - Empty JSON Pin
Richard Deeming13-Jul-22 6:55
mveRichard Deeming13-Jul-22 6:55 
GeneralRe: .Net Framework Web API & Client - Empty JSON Pin
Kevin Marois13-Jul-22 8:14
professionalKevin Marois13-Jul-22 8:14 
QuestionVisual Studio 2022 vs Visual Studio Code for Angular development Pin
Danpeking9-Jun-22 23:20
MemberDanpeking9-Jun-22 23:20 
AnswerRe: Visual Studio 2022 vs Visual Studio Code for Angular development Pin
thatraja2-Aug-22 1:48
professionalthatraja2-Aug-22 1:48 
QuestionSearch Function Pin
Yhanzoe Adigue6-Jun-22 16:28
MemberYhanzoe Adigue6-Jun-22 16:28 
Good Day!

Asking for Help about Asp.Net (vb code) Search Error.

The Scenario is When I search for data, I get it. Then when I search again, I get the error "System.NullReferenceException: 'Object reference not set to an instance of an object.'"

How to fix this error?

Thanks and advance.

Here's my code below:

Dim strKeyWord As String
Dim str As String
Dim cmd As New MySqlCommand
Dim da As New MySqlDataAdapter
Dim ds As New DataSet
Dim objConn As New MySqlConnection

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
strKeyWord = Me.txtSEARCH.Text
End Sub


Sub BindData()

Try

strConnString = "Host=;userid=;password=;database=;port=3306;"
str = "SELECT * FROM DataDB WHERE (sc_last_name Like '%" & strKeyWord & "%')"
objConn.ConnectionString = strConnString

With cmd
.Connection = objConn
.CommandText = str
.CommandType = CommandType.Text
End With

da.SelectCommand = cmd <---- The error is here when I search again Error: 'Object reference not set to an instance of an object.'
da.Fill(ds)

myGridView.DataSource = ds
myGridView.DataBind()

da = Nothing
objConn.Close()
objConn = Nothing
cmd.Dispose()

Catch ex As Exception
MsgBox(ex.Message)
End Try


End Sub

Sub myGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim lblID As Label = CType(e.Row.FindControl("lblID"), Label)

If Not IsNothing(lblID) Then
lblID.Text = e.Row.DataItem("ID")
End If


Dim lblLN As Label = CType(e.Row.FindControl("lbLN"), Label)

If Not IsNothing(lblLN) Then
lblLN.Text = e.Row.DataItem("sc_last_name")
End If


Dim lblFN As Label = CType(e.Row.FindControl("lblFN"), Label)

If Not IsNothing(lblFN) Then
lblFN.Text = e.Row.DataItem("sc_first_name")
End If


Dim lblBDAY As Label = CType(e.Row.FindControl("lblBDAY"), Label)

If Not IsNothing(lblBDAY) Then
lblBDAY.Text = e.Row.DataItem("sc_dob")

End If

End Sub

Sub ShowPageCommand(ByVal s As Object, ByVal e As GridViewPageEventArgs)

myGridView.PageIndex = e.NewPageIndex
BindData()

End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

BindData()

End Sub



modified 7-Jun-22 6:59am.

AnswerRe: Search Function Pin
Pete O'Hanlon6-Jun-22 20:41
mvaPete O'Hanlon6-Jun-22 20:41 
QuestionI'm trying to interact with a select element with selenium Pin
lucas lima 202229-May-22 13:25
Memberlucas lima 202229-May-22 13:25 
AnswerRe: I'm trying to interact with a select element with selenium Pin
behruz1230-Jul-22 19:40
Memberbehruz1230-Jul-22 19:40 
QuestionNew MVC5 project, Bootstrap update, Fail Pin
#realJSOP26-May-22 4:41
mva#realJSOP26-May-22 4:41 
AnswerRe: New MVC5 project, Bootstrap update, Fail Pin
Richard Deeming26-May-22 21:41
mveRichard Deeming26-May-22 21:41 
AnswerRe: New MVC5 project, Bootstrap update, Fail Pin
Matthew Dennis27-May-22 4:18
sysadminMatthew Dennis27-May-22 4:18 
GeneralRe: New MVC5 project, Bootstrap update, Fail Pin
#realJSOP27-May-22 10:12
mva#realJSOP27-May-22 10:12 
QuestionIMAP and SMTP Server Pin
Aashna Khanna24-May-22 21:42
professionalAashna Khanna24-May-22 21:42 
AnswerRe: IMAP and SMTP Server Pin
Richard MacCutchan24-May-22 22:01
mveRichard MacCutchan24-May-22 22:01 
QuestionMVC5 Project Template Pin
#realJSOP13-May-22 0:06
mva#realJSOP13-May-22 0:06 
QuestionHow to send Email From Multiple SMTP In One shot. Pin
Ramendra Kumar Sinha11-May-22 18:52
MemberRamendra Kumar Sinha11-May-22 18:52 
AnswerRe: How to send Email From Multiple SMTP In One shot. Pin
Richard Deeming11-May-22 21:41
mveRichard Deeming11-May-22 21:41 
QuestionFont colour and background colour combinations hard to read Pin
Ross_Petersen2-May-22 22:24
professionalRoss_Petersen2-May-22 22:24 
AnswerRe: Font colour and background colour combinations hard to read Pin
Member 150787164-Jul-22 16:00
MemberMember 150787164-Jul-22 16:00 
Questionhow do I get total quantity from this code Pin
wixily jnr28-Apr-22 13:26
Memberwixily jnr28-Apr-22 13:26 
AnswerRe: how do I get total quantity from this code Pin
Richard MacCutchan28-Apr-22 21:32
mveRichard MacCutchan28-Apr-22 21:32 
GeneralRe: how do I get total quantity from this code Pin
wixily jnr29-Apr-22 8:17
Memberwixily jnr29-Apr-22 8:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.