且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何更新现有的Sql Ce记录

更新时间:2023-12-02 21:30:40

Hie

我设法从你给我的链接中提取某些信息并且它有效。我刚刚创建了一个示例数据库,并提供了以下更新查询:

尝试

Dim描述为String = TextBox4.Text



Dim Row()As Data.DataRow

Row = ds.Tables(Persons)。Select(PersonsID = 54)

Row( 0)(名称)=说明





Dim q作为新的SqlCeCommand(UPDATE Persons SET Name = @ Name,Phone = @Phone,其中PersonsID = 54,conn)

For i = 0 to ds.Tables(Persons)。Rows.Count - 1









q.Parameters.Add(新的SqlCeParameter(@ Name,ds.Tables(Persons)。行(i)(名称)))

q.Parameters.Add(新的SqlCeParameter(@ Phone,ds.Tables(Persons)。行(i)(电话) )))



q.ExecuteNonQuery()

下一页





Catch ex As Exception

MsgBox(ex.Message)

结束尝试

结束次级

最后,经过两天的挠头之后。这真的很好,多亏你,感谢你。
Hie
I have managed to extract certain information from the link you gave me and it worked. I just created a sample database and i put the following update query:
Try
Dim Description As String = TextBox4.Text

Dim Row() As Data.DataRow
Row = ds.Tables("Persons").Select("PersonsID = 54")
Row(0)("Name") = Description


Dim q As New SqlCeCommand("UPDATE Persons SET Name=@Name,Phone=@Phone where PersonsID = 54", conn)
For i = 0 To ds.Tables("Persons").Rows.Count - 1




q.Parameters.Add(New SqlCeParameter("@Name", ds.Tables("Persons").Rows(i)("Name")))
q.Parameters.Add(New SqlCeParameter("@Phone", ds.Tables("Persons").Rows(i)("Phone")))

q.ExecuteNonQuery()
Next


Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
At last, after two days of scratching my head. It really worked fine, thanks to you man.