Click here to Skip to main content
15,908,931 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionReally Dim Question... Pin
Dalek Dave21-Mar-12 4:59
professionalDalek Dave21-Mar-12 4:59 
AnswerRe: Really Dim Question... Pin
Pete O'Hanlon21-Mar-12 5:57
mvePete O'Hanlon21-Mar-12 5:57 
GeneralRe: Really Dim Question... Pin
Dalek Dave21-Mar-12 6:30
professionalDalek Dave21-Mar-12 6:30 
GeneralRe: Really Dim Question... Pin
Pete O'Hanlon21-Mar-12 6:37
mvePete O'Hanlon21-Mar-12 6:37 
AnswerRe: Really Dim Question... Pin
Vasudevan Deepak Kumar21-Mar-12 6:55
Vasudevan Deepak Kumar21-Mar-12 6:55 
Questiondynamically creating aspx pages using xslt and xml Pin
kasakrajesh21-Mar-12 4:02
kasakrajesh21-Mar-12 4:02 
AnswerRe: dynamically creating aspx pages using xslt and xml Pin
Not Active21-Mar-12 4:14
mentorNot Active21-Mar-12 4:14 
Questionneed help with gridview and sql Pin
Dylan98821-Mar-12 3:43
Dylan98821-Mar-12 3:43 
Hi, i am currently doing a project on web service for wine. i have the wine table with wineName and wineType. Also i have the search function implemented in the webservice coding as well as a separate webform to call the function of the search function.

I have the following code for performing search in the search service:

VB
<WebMethod()> _
   Public Function Search(ByVal searchName As String) As System.Data.DataSet
       Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
       Dim con As New SqlConnection(connectionString)

       Dim selectSql As String = "SELECT * From Wine WHERE WineType='" & searchName + "'"

       Dim selectAdapter As New Data.SqlClient.SqlDataAdapter(selectSql, con)
       Dim ds As New Data.DataSet
       con.Open()
       selectAdapter.Fill(ds, "Wine")
       con.Close()

       Return ds

   End Function


As for the webform, it's just a simple page with textbox labeled as searchName, a button and a gridView1 tied to ObjectDataSource.

This is the coding i have for webform:
VB
Partial Class Search
    Inherits System.Web.UI.Page


    Dim searching As searchwine.Service = New searchwine.Service

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If searchName.Text = "" Then
            lblDisplayError.Text = "Can't search empty field!"
        Else
            Dim ds As DataSet = searching.Search(searchName.Text)
            GridView1.DataSource = ds.Tables(0)
            GridView1.DataBind()
            GridView1.Visible = True
            lblDisplayError.Visible = False

        End If


    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        lblDisplayError.Text = ""
        GridView1.Visible = False
    End Sub
End Class


Everything seems fine but i have the following error when i want to do a search:

System.NullReferenceException: Object reference not set to an instance of an object.
  at Service.Search(String searchName)


Can anyone help me out please? thank you very much
QuestionRe: need help with gridview and sql Pin
ZurdoDev21-Mar-12 4:14
professionalZurdoDev21-Mar-12 4:14 
AnswerRe: need help with gridview and sql Pin
Dylan98821-Mar-12 4:29
Dylan98821-Mar-12 4:29 
GeneralRe: need help with gridview and sql Pin
ZurdoDev21-Mar-12 4:33
professionalZurdoDev21-Mar-12 4:33 
GeneralRe: need help with gridview and sql Pin
Dylan98821-Mar-12 4:45
Dylan98821-Mar-12 4:45 
GeneralRe: need help with gridview and sql Pin
ZurdoDev21-Mar-12 4:51
professionalZurdoDev21-Mar-12 4:51 
GeneralRe: need help with gridview and sql Pin
Dylan98821-Mar-12 4:58
Dylan98821-Mar-12 4:58 
GeneralRe: need help with gridview and sql Pin
ZurdoDev21-Mar-12 5:04
professionalZurdoDev21-Mar-12 5:04 
AnswerRe: need help with gridview and sql Pin
Anudeep Jaiswal - MCA28-Mar-12 23:07
Anudeep Jaiswal - MCA28-Mar-12 23:07 
Questionread byte of saved picture Pin
comptech219-Mar-12 21:21
comptech219-Mar-12 21:21 
AnswerRe: read byte of saved picture Pin
Not Active20-Mar-12 22:47
mentorNot Active20-Mar-12 22:47 
GeneralRe: read byte of saved picture Pin
comptech221-Mar-12 9:04
comptech221-Mar-12 9:04 
GeneralRe: read byte of saved picture Pin
Not Active21-Mar-12 9:22
mentorNot Active21-Mar-12 9:22 
GeneralRe: read byte of saved picture Pin
comptech221-Mar-12 9:47
comptech221-Mar-12 9:47 
GeneralRe: read byte of saved picture Pin
Not Active21-Mar-12 9:50
mentorNot Active21-Mar-12 9:50 
AnswerRe: read byte of saved picture Pin
satalaj21-Mar-12 6:34
satalaj21-Mar-12 6:34 
GeneralRe: read byte of saved picture Pin
comptech221-Mar-12 9:13
comptech221-Mar-12 9:13 
GeneralRe: read byte of saved picture Pin
shreekar21-Mar-12 10:13
shreekar21-Mar-12 10:13 

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.