0 Replies - 781 Views - Last Post: 20 March 2017 - 03:04 PM

#1 grabbetje  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 22-February 17

Unable to Update my DataBase ASP.Net in VB

Posted 20 March 2017 - 03:04 PM

Im Getting closer to a solution, but as im running out of options im asking for your help.
I'm having trouble updating data to my sql db from Code behind. The Formlayout (devexpress) fill's itselves true the Sql DataSource with data. When i try to edit a file, that i select with my DropDownlist control, and try to save it. It doesn,t send the updated data to my DB server.

Any suggestion what im missing here?

Many Thanks for your help.


Partial Public Class _Default

    Inherits Page
    Dim sql As String = String.Empty
    Dim con As Data.SqlClient.SqlConnection
    Dim cmd As Data.SqlClient.SqlCommand
    Dim bReturn As Boolean = False
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Try
            sql = "SELECT * FROM [Tbl_projectDetailRoof]" 
            con = New Data.SqlClient.SqlConnection("Data Source=xx.xxx.x.xxx,xxxx;Persist Security Info=True;User ID=xxxxxx;Password=xxxxxxx") 
            con.Open() 
            cmd = New Data.SqlClient.SqlCommand(sql, con) 
            cmd.ExecuteNonQuery() 
            bReturn = True 
        Catch ex As Exception

            bReturn = False
        Finally
            '-- 10.0 always close that connection!
            If con IsNot Nothing Then con.Dispose()
        End Try
    End Sub
    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Try
            SqlDataSource1.UpdateParameters("projectdetailroofID").DefaultValue = DropDownList1.SelectedItem.Value
            SqlDataSource1.Update()
            ASPxFormLayout1.DataBind()

        Catch ex As Exception
            MessageLabel.Text = ex.Message
            MessageLabel.Visible = True
        End Try
    End Sub

End Class


Is This A Good Question/Topic? 0
  • +

Page 1 of 1