Execute non Query

prav_roy

Well-known member
Joined
Sep 10, 2005
Messages
70
Location
Mumbai
Programming Experience
1-3
when i execute the following querry i get the error saying

Operation must use an updateable query

my code goes like this

Dim com As OleDbCommand = New OleDbCommand("insert into ajit (name,age)values('" & TextBox2.Text & "','" & TextBox3.Text & "')", dbconn)
dbconn.Open()
com.ExecuteNonQuery()
dbconn.Close()

can anybody help me in finding out the error, also tel me is this method of inserting into database is effective, is not suggest me an alternative
 
I'm no ADO guru but you could try this...

Dim com as oledbcommand = New OleDbCommand("INSERT INTO [ajit] (name, age) VALUES (?,?)",dbconn)
com.parameters.add("@name" , oledbtype.varwchar , 50 ,"name").Value = textbox2.text
com.parameters.add("@age" , oledbtype.integer, 0 , "age").value = textbox3.text
dbconn.open
com.executenonquery
dbconn.close
 

Latest posts

Back
Top