Run-time exception thrown : - 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.

Run-time exception thrown :

pompai2005pompai2005 Posts: 5Member
[color=Blue]following code in vb script arising no error(i.e. debugging without any error, even then not inserting data from those three textbox control into the access database name.mdb having the table details,after clicking the button named btnadd)
com.ExecuteNonQuery() Run-time exception thrown : System.Data.OleDb.OleDbException - Operation must use an updateable query. [/color]


sub btnadd(sender as object,e as eventargs)

dim con as OleDBConnection
dim com as OleDBCommand
dim str as string
dim i as integer

try
con=new OleDBConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:WebSitedatabase2
ame.mdb;")
con.open()
str="insert into details values("&(t1.text)&","&(t2.text)&","&Cint(t3.text)&")"
com=new OleDBCommand(str,con)
i=com.Executenonquery()
if i>0 then
l1.text="one record added"
end if
catch es as exception
l1.text=es.message
finally
con.close()
end try

end sub

--------------------

















[color=Blue]SOLUTION???????????

Anirban Chakraborty
[email protected][/color]

Comments

  • bradwangbradwang Posts: 197Member
    You need to grant the ASPNET user the write permission to the ACCESS MDB file. Otherwise, you will see the above error...

    [color=Green][size=1][b]Brad Wang - .NET Freelancer from China
    MSN: [email protected]
    Skype: brad_wang[/b][/size][/color]
  • pompai2005pompai2005 Posts: 5Member
    : You need to grant the ASPNET user the write permission to the ACCESS
    : MDB file. Otherwise, you will see the above error...
    :
    : [color=Green][size=1][b]Brad Wang - .NET Freelancer from China
    : MSN: [email protected]
    : Skype: brad_wang[/b][/size][/color]

    Thanks Brad,

    Eventually I checked that,but again I found one more bug in the following code.Plz help!

    //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!
    [email protected]



Sign In or Register to comment.