Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Update tables using DataAdapater and Sql stored procedures? 1

Status
Not open for further replies.

svu

Programmer
Apr 10, 2000
30
TH
Hi all,

I want to make a databound simple data entry form, using Sql stored procedures. I am using DataAdapater and DataSet.

I am using four stored procedures for Select, Update, Insert and Delete.

How can use the above stored procedures with DataAdapater to write changes to DataBase using DataSet...?

Thanks for your help in advance.
 

Why don't you use Data Access Application Block. It provides an optimized mechanism for most common data access tasks with SQL Server.

Get detailed information about Data Access Application Block under FAQs.

Email: pankajmsm@yahoo.com
 
pankaj, thank you very much for your attention. I'm very new to dotnet. Majorly into database application development. In the samples, i could c various methods of data retreival and updation. I found the databinding one very easy and good to use. i define a data adapter, define the select, update, insert and delete stored procedures. Now, my problem is what should i pass as parameter to these queries. for eg. to the update command parameter i pass "txtcustname.text" as parameter. It does not work. Can u pls help me with what should be passed as parameters? all the controls on the form are databound. But when i change the text it updates in the temporary dataset but does not update the database when dataAdapter.update(data set) is fired.
Thanks for your help.
 

can u post the code you have writtem to pass the parameters

Email: pankajmsm@yahoo.com
 
Private Sub FrmShpSql_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
daShape.SelectCommand = New SqlCommand("listshapes", conShape)
daShape.SelectCommand.CommandType = CommandType.StoredProcedure
daShape.SelectCommand.Parameters.Add("@name", SqlDbType.VarChar, 2).Value = "%%"
daShape.SelectCommand.Parameters.Add("@shortname", SqlDbType.VarChar, 2).Value = "%%"

daShape.UpdateCommand = New SqlCommand("updateshape", conShape)
daShape.UpdateCommand.CommandType = CommandType.StoredProcedure
daShape.UpdateCommand.Parameters.Add("@ID", SqlDbType.VarChar, 30, "sid")
daShape.UpdateCommand.Parameters.Add("@name", SqlDbType.VarChar, 30, "shapename")
daShape.UpdateCommand.Parameters.Add("@shortname", SqlDbType.VarChar, 30, "shortname")

Try
daShape.Fill(dsShapes, "tblshape")
Catch exp As Exception
MsgBox(exp.ToString)
End Try
TxtSid.DataBindings.Add("text", dsShapes.Tables("tblshape"), "sid")
txtShapeName.DataBindings.Add("text", dsShapes.Tables("tblshape"), "shapename")
txtShortName.DataBindings.Add("text", dsShapes.Tables("tblshape"), "shortname")
end sub

I dont know what values to be passed to the parameters in updatecommand viz. @ID, @name & @shortname.
pls suggest.
 
Dear Pankaj,

My problem is solved. I was missing the source column property.

Thank you very much for help and attention.

Regards
SVU
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top