Hello All,
I wanna ask, if i have an sql server....how these codes will be written..they are using OLeDb....should I just change the word OleDb with SQl?
Update example:-
Dim key as String = Datagrid1.DataK eys(e.Item.Item Index)
StoryDA.SelectC ommand.CommandT ext = "SELECT * FROM Story_Master WHERE SID=" & key
StoryDA.UpdateC ommand = OleDbUpdateComm and1
Dim workParm As OleDbParameter = StoryDA.UpdateC ommand.Paramete rs.Add(key, OleDbType.Integ er)
workParm.Source Column = "SID"
workParm.Source Version = DataRowVersion. Original
StoryDA.Fill(St orySet)
Dim workrow As DataRow = StorySet.Story_ Master.Rows(0)
workrow("Story_ Section") = drplistSection. SelectedItem.To String
Try
StoryDA.Update( StorySet)
Response.Redire ct("Edit_Story. aspx?SID=" & Request.QuerySt ring("SID") & "&Type=Updated" )
Catch ex As Exception
lblErr.Text = ex.Message
End Try
Delete Example:
Code:
Dim key As String = StoryDG.DataKey s(e.Item.ItemIn dex).ToString()
Dim catDA As OleDbDataAdapte r = New OleDbDataAdapte r("SELECT * FROM Story_Master WHERE SID =" & key, OleDbConnection 1)
catDA.DeleteCom mand = New OleDbCommand("D ELETE FROM Story_Master WHERE SID = ?", OleDbConnection 1)
Dim workParm As OleDbParameter = catDA.DeleteCom mand.Parameters .Add(key, OleDbType.Integ er)
workParm.Source Column = "SID"
workParm.Source Version = DataRowVersion. Original
Dim catDS As DataSet = New DataSet
catDA.Fill(catD S, "Story_Mast er")
Dim cRow As DataRow = catDS.Tables("S tory_Master").R ows(0)
cRow.Delete()
Dim modRows() As DataRow = catDS.Tables("S tory_Master").S elect(Nothing, Nothing, DataViewRowStat e.Deleted)
Try
catDA.Update(mo dRows)
Catch ex As Exception
Response.Write( ex.Message)
End Try
I wanna ask, if i have an sql server....how these codes will be written..they are using OLeDb....should I just change the word OleDb with SQl?
Update example:-
Dim key as String = Datagrid1.DataK eys(e.Item.Item Index)
StoryDA.SelectC ommand.CommandT ext = "SELECT * FROM Story_Master WHERE SID=" & key
StoryDA.UpdateC ommand = OleDbUpdateComm and1
Dim workParm As OleDbParameter = StoryDA.UpdateC ommand.Paramete rs.Add(key, OleDbType.Integ er)
workParm.Source Column = "SID"
workParm.Source Version = DataRowVersion. Original
StoryDA.Fill(St orySet)
Dim workrow As DataRow = StorySet.Story_ Master.Rows(0)
workrow("Story_ Section") = drplistSection. SelectedItem.To String
Try
StoryDA.Update( StorySet)
Response.Redire ct("Edit_Story. aspx?SID=" & Request.QuerySt ring("SID") & "&Type=Updated" )
Catch ex As Exception
lblErr.Text = ex.Message
End Try
Delete Example:
Code:
Dim key As String = StoryDG.DataKey s(e.Item.ItemIn dex).ToString()
Dim catDA As OleDbDataAdapte r = New OleDbDataAdapte r("SELECT * FROM Story_Master WHERE SID =" & key, OleDbConnection 1)
catDA.DeleteCom mand = New OleDbCommand("D ELETE FROM Story_Master WHERE SID = ?", OleDbConnection 1)
Dim workParm As OleDbParameter = catDA.DeleteCom mand.Parameters .Add(key, OleDbType.Integ er)
workParm.Source Column = "SID"
workParm.Source Version = DataRowVersion. Original
Dim catDS As DataSet = New DataSet
catDA.Fill(catD S, "Story_Mast er")
Dim cRow As DataRow = catDS.Tables("S tory_Master").R ows(0)
cRow.Delete()
Dim modRows() As DataRow = catDS.Tables("S tory_Master").S elect(Nothing, Nothing, DataViewRowStat e.Deleted)
Try
catDA.Update(mo dRows)
Catch ex As Exception
Response.Write( ex.Message)
End Try
Comment