Click here to Skip to main content
15,887,596 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Self Signed Cert Questions Pin
Richard Deeming1-Aug-22 0:17
mveRichard Deeming1-Aug-22 0:17 
GeneralRe: Self Signed Cert Questions Pin
Kevin Marois1-Aug-22 10:40
professionalKevin Marois1-Aug-22 10:40 
GeneralRe: Self Signed Cert Questions Pin
Richard Deeming1-Aug-22 21:34
mveRichard Deeming1-Aug-22 21:34 
GeneralRe: Self Signed Cert Questions Pin
Kevin Marois9-Aug-22 7:14
professionalKevin Marois9-Aug-22 7:14 
GeneralRe: Self Signed Cert Questions Pin
Richard Deeming9-Aug-22 7:29
mveRichard Deeming9-Aug-22 7:29 
GeneralRe: Self Signed Cert Questions Pin
Kevin Marois9-Aug-22 12:12
professionalKevin Marois9-Aug-22 12:12 
GeneralRe: Self Signed Cert Questions Pin
Richard Deeming10-Aug-22 1:24
mveRichard Deeming10-Aug-22 1:24 
GeneralRe: Self Signed Cert Questions [UPDATED] Pin
Kevin Marois10-Aug-22 8:47
professionalKevin Marois10-Aug-22 8:47 
GeneralRe: Self Signed Cert Questions [UPDATED] Pin
Richard Deeming10-Aug-22 21:52
mveRichard Deeming10-Aug-22 21:52 
GeneralRe: Self Signed Cert Questions [UPDATED] Pin
Kevin Marois11-Aug-22 5:39
professionalKevin Marois11-Aug-22 5:39 
QuestionDisplay snowflake data into visualization format Pin
jebasgp20-Jul-22 1:51
jebasgp20-Jul-22 1:51 
AnswerRe: Display snowflake data into visualization format Pin
CHill6020-Jul-22 2:31
mveCHill6020-Jul-22 2:31 
Question.Net Framework Web API & Client - Empty JSON Pin
Kevin Marois11-Jul-22 16:56
professionalKevin Marois11-Jul-22 16:56 
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
Kevin 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 
GeneralMessage Closed Pin
13-Jul-22 6:24
professionalKevin Marois13-Jul-22 6:24 
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
Danpeking9-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 
AnswerRe: Visual Studio 2022 vs Visual Studio Code for Angular development Pin
Jeremy Falcon15-Dec-22 13:14
professionalJeremy Falcon15-Dec-22 13:14 
AnswerRe: Visual Studio 2022 vs Visual Studio Code for Angular development Pin
Nitin S11-Apr-23 18:14
professionalNitin S11-Apr-23 18:14 
QuestionSearch Function Pin
Yhanzoe Adigue6-Jun-22 16:28
Yhanzoe 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
mvePete O'Hanlon6-Jun-22 20:41 

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.