.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Insert+update data

Posted By: Baiju EP     Posted Date: September 10, 2012    Points:5   Category :ASP.Net
i have a asp.net+vb(code)+sql database website.

tables are emp_data and anil_data

i want to copy regnumber,name,firm,appt,dtin,remark from anil_data and one textbox input(date) into emp_data

and update the anil_data with new data filled in some textboxes
i used the following code

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim con As New SqlConnection
con.ConnectionString = ConfigurationManager.ConnectionStrings("ANILConnectionString").ConnectionString
con.Open()
Dim sql_ins As String
sql_ins = "insert into emp_data select regnumber,name,firm,appt,dtin,remark from anil_data where regnumber='" + notxt.Text + "'"
Dim sqlcom As New SqlCommand(sql_ins, con)
sqlcom.ExecuteNonQuery()
Page.ClientScript.RegisterStartupScript(Me.GetType, "Forms", "<script> alert('Record Moved Successfully........')</script>")
Dim qstr As String
qstr = "update anil_DATA set firm=@a,appt=@b,indt=@c, regnumber=@regnumber where regnumber=@regnumber"
Dim sql1 As New SqlCommand(qstr, con)
sql1.Parameters.Add(New SqlParameter("@a", SqlDbType.VarChar, 50)).Value = firmtxt.Text
sql1.Parameters.Add(New SqlParameter("@b", SqlDbType.VarChar, 25)).Value = appttxt.Text
sql1.Parameters.Add(New SqlParameter("@j", SqlDbType.DateTime)).Value = indttxt.Text
sql1.Parameters.Add(New SqlParameter("@pnumb", SqlDbType.VarChar, 200)).Value = persno.Text
End Sub

till here it works fine if there is no field named SOS in emp_data table. if i add that field the sql_in gives error that th e coloumn doesnot match

there is a textbox named sostxt. i want to insert value (date) of that text into emp_data (SOS field) alongwith the insert into script.

sql1.Parameters.Add(New SqlParameter("@a", SqlDbType.DateTime)).Value = sostxt.Text

how can it be done

Responses
Author: Jack Smith             
Posted Date: September 10, 2012     Points: 20   

Insert data and update data in asp.net with my sql is progressive code but you don't describe that finishing process so please give it.

Click Here for More Information about .Net Developer of India
Author: Jack Smith             
Posted Date: September 10, 2012     Points: 20   

Insert data and update data in asp.net with my sql is progressive code but you don't describe that finishing process so please give it.

Click Here for More Information about .Net Developer of India
Author: Baimey Rajesh             
Posted Date: September 11, 2012     Points: 20   

Hi Smith,

Sorry to tell you.
Please be careful, do not enter REPEATED ANSWERS.

If you have a mistake you can edit and submit again. :)

Thanks
Baimey

Author: Baiju EP             
Posted Date: September 11, 2012     Points: 20   

really this is the script i am using and it works except for sostxt.text



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend