search engine web application in asp.net and vb - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

search engine web application in asp.net and vb

pompai2005pompai2005 Posts: 5Member
//error is:"No value given for one or more required parameters". is arising in web application written in vb.
This is a search engine I am designing.








Sub save_onclick(ByVal Sender As Object, ByVal E As EventArgs)


// I declared required variable here




conn_str = ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:
ame.mdb;")


//name.mdb holds table "details" contains fields name(text),address(text),phone(number)


cn = New OleDbConnection(conn_str)
cn.Open()
str = "insert into details values ('" & (t1.Text) & "','" & (t2.Text) & "', " & (t3.Text) & " );"


//t1=id of name textbox
//t2=id of address textbox
//t3=id of phone textbox


com = New OleDbCommand(str, cn)
com.ExecuteNonQuery()
sql = "select * from details"
adap = New OleDbDataAdapter(sql, cn)
ds = New DataSet()
adap.Fill(ds, "details")
dtgrid.DataSource = ds.Tables("details").DefaultView
dtgrid.DataBind()


ddl1.DataSource = ds.Tables("details").DefaultView
ddl1.DataTextField = "name"
ddl1.DataBind()

ddl2.DataSource = ds.Tables("details").DefaultView
ddl2.DataTextField = "address"
ddl2.DataBind()

ddl3.DataSource = ds.Tables("details").DefaultView
ddl3.DataTextField = "phone"
ddl3.DataBind()
cn.Close()
End sub

Sub search(ByVal sender As Object, ByVal e As EventArgs)


//I declared required variable here

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:WebSitedatabase2
ame.mdb;")
cn.Open()


//error arising here onwards
//complex query string
//error is:No value given for one or more required parameters.
//what will be the query string to find the search result after selecting value from any and all of those three drop down list to be displayed in the grid



str = "select * from details where "
If ddl1.Text <> "" Then
str = str + "name = " + ddl1.Text.ToString + ";"
ElseIf ddl2.Text <> "" Then
str = str + "address = " + ddl2.Text.ToString + ";"
ElseIf ddl3.Text <> "" Then
str = str + "phone = " + ddl3.Text.ToString + ";"
End If

adap = New OleDbDataAdapter(str, cn)
ds = New DataSet()
adap.Fill(ds, "details")
dtgrid.DataSource = ds2.Tables("details").DefaultView
dtgrid.DataBind()
cn.Close()


//error upto this



End Sub






















solution is welcome


dont hesitate to notify me at following e-mail.

This would make sense to me.

Thanks!
pompai2005@gmail.com

Comments

  • bradwangbradwang Posts: 197Member
    Should you add single quote in the following code snippet:

    If ddl1.Text <> "" Then
    str = str + "name = " + ddl1.Text.ToString + ";"
    ElseIf ddl2.Text <> "" Then
    str = str + "address = " + ddl2.Text.ToString + ";"
    ElseIf ddl3.Text <> "" Then
    str = str + "phone = " + ddl3.Text.ToString + ";"
    End If

    To:

    If ddl1.Text <> "" Then
    str = str + " and name = '" + ddl1.Text.ToString + "' "
    ElseIf ddl2.Text <> "" Then
    str = str + " and address = '" + ddl2.Text.ToString + "'"
    ElseIf ddl3.Text <> "" Then
    str = str + " and phone = " + ddl3.Text.ToString
    End If

    ?

    Also, I notice you are doing the asp.net programming much the classic asp way. Therefore, I suspect you are quite new to the language and the .NET platform? If so, you really need to take some time and some good tutorials to learn the basics first. :)

    [color=Green][size=1][b]Brad Wang - .NET Freelancer from China
    MSN: brad_wang_cn@hotmail.com
    Skype: brad_wang[/b][/size][/color]
Sign In or Register to comment.