Forums

ASP

This topic is locked

search engine web-application in asp.net and vb

Posted 23 Aug 2008 07:08:01
1
has voted
23 Aug 2008 07:08:01 anirban chakraborty posted:
//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.



<html>
<head runat="server">
<script language =vbscript runat =server >


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:\name.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:\WebSite\database2\name.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


</script>
</head>




<body>
<form id="form1" runat="server">

<aspropDownList ID=ddl1 runat =server />
<aspropDownList ID=ddl2 runat =server />
<aspropDownList ID=ddl3 runat =server />
<asp:button id="button1" onclick="save_onclick" Runat="server" Text="SAVE"/>
<asp:Button ID=button2 runat =server Text =SEARCH OnClick =search />

</form>
</body>
</html>


solution is welcome


dont hesitate to notify me at following e-mail.

This would make sense to me.

Thanks!

Reply to this topic