| | |
update the whole table
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 85
Reputation:
Solved Threads: 3
hii all, i have a query,,it might be simple bt i hav no idea how to do it,,i am creating an application in VB lang using asp.net 2005 and sql server 2005. in my form i have a combo box which displays all the table names from my database say dat1..i have created another database say dat2 with same table n their datatypes..,what i want is when i select a table name and click on update button then the table in dat2 database should be updated with the records from table in dat1.. well i have achieved this but i cant say it as updating..
heres is may code on update button
can ne1 help,,,reply asap,,,thnks in advance
heres is may code on update button
ASP.NET Syntax (Toggle Plain Text)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If conn11.State = ConnectionState.Closed Then conn11.Open() End If If conn12.State = ConnectionState.Closed Then conn12.Open() End If Dim strins As String Dim strdel As String Dim txt1 As String txt1 = ComboBox1.Text If Not txt1 = "" Then strins = "IF EXISTS(SELECT name FROM sys.tables WHERE name = '" & txt1 & "') select * from " & txt1 MsgBox(strins) cmd = New SqlCommand(strins, conn12) dr.Close() dr = cmd.ExecuteReader If dr.Read Then MsgBox("table exists") strdel = "delete from [jay1].dbo. " & txt1.ToString MsgBox(strdel) cmd = New SqlCommand(strdel, conn12) dr.Close() dr = cmd.ExecuteReader MsgBox("records deleted") strins = "insert into [jay1].dbo." & txt1.ToString & " select * from [jay].dbo." & txt1.ToString MsgBox(strins) cmd = New SqlCommand(strins, conn12) dr.Close() dr = cmd.ExecuteReader MsgBox("records inserted into new database") Else MsgBox("table doesnot exist") strins = "select * into [jay1].dbo. " & txt1.ToString & " from [jay].dbo. " & txt1.ToString MsgBox(strins) cmd = New SqlCommand(strins, conn12) dr.Close() dr = cmd.ExecuteReader MsgBox("new table created and records inserted") End If Else MsgBox("table not selected") End If End Sub
Johnny.G
•
•
Join Date: Feb 2008
Posts: 85
Reputation:
Solved Threads: 3
ooohh dear,,k i wil explain it again wht i want,,in my application i have two database,,but the tables in both the database r exactly same,all the updation occurs in the tables of 1st database.currently in my form i am creating a new table if it doesnot exists in database2 and fill it with the data from the table in database1,,if the table exists then i delete all the records in the table from database 2 and the insert all the details from the table in database 1...what i want is instead of deleting the data and then inserting it from the table i would like to update the table in database 2 from the table in database 1....hop u got ma prob,,,let me kno whethr u got it or not,,,waiting for ur reply,,thnks in advance
Johnny.G
![]() |
Similar Threads
- unable to update my table (PHP)
- Inserting table row values generated dynamically into database using JSP (JSP)
- Two update statements (MS SQL)
- mysql update help??? (PHP)
- Not able to change/update password (PHP)
- Add an attribute to existing table (Database Design)
- How can i deledet and update from table ??????? (PHP)
Other Threads in the ASP.NET Forum
- Previous Thread: Display client's PC Date & Time
- Next Thread: Upload File
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers





