|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Dataset in ADO.NET
I am trying to execute the code below but it did not work.<br><br>I want to write the changes to the database but it did not work<br><br>Dim myConn As New SqlClient.SqlConnection("server=ns1;database=dotnet;uid=sa;pwd=hiban")<br> Dim myDataAdapter As New SqlClient.SqlDataAdapter("Select * from vistors", myConn)<br> Dim custDS As DataSet = New DataSet("vistors")<br> Dim DS As New DataSet()<br> Dim datar As New DataRow()<br> myConn.Open()<br><br> myDataAdapter.Fill(custDS, "vistors")<br> custDS.Tables("vistors").Rows(0)(1) = "Alaa Salmo"<br> 'TextBox1.Text = custDS.Tables("vistors").Rows(0)(1)<br> datar = custDS.Tables("vistors").NewRow()<br><br> custDS.AcceptChanges()<br> custDS.GetChanges(DataRowState.Modified)<br> If Not custDS.HasChanges(DataRowState.Modified) Then<br> myDataAdapter.Update(custDS, "vistors")<br> Else<br> MsgBox("No change")<br> End If<br><br><br> myConn.Close()<br><br><br>How can I make the changes to the database ,not only to the recordset
|
|
#2
|
|||
|
|||
|
<img border="0" src="/forum/emoticons/smilewinkgrin.gif" height="15" width="15" alt="smilewinkgrin" /> <br>Just looking at the cod, I noticed the following:<br><br>custDS.AcceptChanges()<br>custDS.GetChanges(DataRowState.Modified)<br>If <b>Not</b> custDS.HasChanges(DataRowState.Modified) Then<br>myDataAdapter.Update(custDS, "vistors")<br>Else<br>MsgBox("No change")<br>End If<br><br>I looks to me like your calling the update only if the data <b>hasn't changed</b>.<br> I think if you droped out the "Not" statment it would work. Sometimes a second pair of eyes helps. <img border="0" src="/forum/emoticons/smile.gif" height="15" width="15" alt=":-)" />
|
|
#3
|
|||
|
|||
|
Have you created update command in the dataadapter<br><br>Heemanshu <img border="0" src="/forum/emoticons/roll.gif" height="15" width="50" alt="roll" />
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Dataset in ADO.NET |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|