Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sql refresh

sql refresh

Scheduled Pinned Locked Moved Database
databasehelpcsharpvisual-studiosecurity
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bapu2889
    wrote on last edited by
    #1

    hello I am new and i have just started learning sql 2005 and i have create small table student with 3 columns studentID,firstname and lastname it's works fine i can insert,delete without any problem but when i delete any antry it dosent refresh the page i mean it delete record from sql database but it shows deleted entry in text boxes but if i close application and restart it it dosent show deleted entry any help this is the code for delete Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim SQL As String = Nothing SQL = "DELETE FROM Student WHERE StudentID = " & TextBox3.Text If MessageBox.Show("Are you sure you want to delete", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = MsgBoxResult.Yes Then conStudent = New Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\bablu\My Documents\Visual Studio 2005\Projects\SQL DataApplication\SQL DataApplication\Student.mdf;Integrated Security=True;User Instance=True") conStudent.Open() Try commStudent = New SqlClient.SqlCommand(SQL, conStudent) commStudent.ExecuteNonQuery() MsgBox("Itemdeleted successfully", MsgBoxStyle.Information) Catch ex As Exception MsgBox(ex.Message) End Try conStudent.Close() conStudent.Dispose() Else Exit Sub End If End Sub any help :confused: waiting for your kind rep. have a nice time thanks

    B M 2 Replies Last reply
    0
    • B bapu2889

      hello I am new and i have just started learning sql 2005 and i have create small table student with 3 columns studentID,firstname and lastname it's works fine i can insert,delete without any problem but when i delete any antry it dosent refresh the page i mean it delete record from sql database but it shows deleted entry in text boxes but if i close application and restart it it dosent show deleted entry any help this is the code for delete Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim SQL As String = Nothing SQL = "DELETE FROM Student WHERE StudentID = " & TextBox3.Text If MessageBox.Show("Are you sure you want to delete", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = MsgBoxResult.Yes Then conStudent = New Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\bablu\My Documents\Visual Studio 2005\Projects\SQL DataApplication\SQL DataApplication\Student.mdf;Integrated Security=True;User Instance=True") conStudent.Open() Try commStudent = New SqlClient.SqlCommand(SQL, conStudent) commStudent.ExecuteNonQuery() MsgBox("Itemdeleted successfully", MsgBoxStyle.Information) Catch ex As Exception MsgBox(ex.Message) End Try conStudent.Close() conStudent.Dispose() Else Exit Sub End If End Sub any help :confused: waiting for your kind rep. have a nice time thanks

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      after you delete row then close and open connection conStudent.Close() conStudent.Open() for more information check this[^]


      I Love T-SQL

      B 1 Reply Last reply
      0
      • B Blue_Boy

        after you delete row then close and open connection conStudent.Close() conStudent.Open() for more information check this[^]


        I Love T-SQL

        B Offline
        B Offline
        bapu2889
        wrote on last edited by
        #3

        hello first of all thanks for your rep. i have tried it but it's not working this is the code conStudent.Open() Try commStudent = New SqlClient.SqlCommand(SQL, conStudent) commStudent.ExecuteNonQuery() conStudent.Close() <------:confused: conStudent.Open() <------:confused: MsgBox("Item deleted", MsgBoxStyle.Information) Catch ex As Exception MsgBox(ex.Message) End Try conStudent.Close() conStudent.Dispose() is this what you are saying or some thing else waiting for your kid rep. have a nice day

        1 Reply Last reply
        0
        • B bapu2889

          hello I am new and i have just started learning sql 2005 and i have create small table student with 3 columns studentID,firstname and lastname it's works fine i can insert,delete without any problem but when i delete any antry it dosent refresh the page i mean it delete record from sql database but it shows deleted entry in text boxes but if i close application and restart it it dosent show deleted entry any help this is the code for delete Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim SQL As String = Nothing SQL = "DELETE FROM Student WHERE StudentID = " & TextBox3.Text If MessageBox.Show("Are you sure you want to delete", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = MsgBoxResult.Yes Then conStudent = New Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\bablu\My Documents\Visual Studio 2005\Projects\SQL DataApplication\SQL DataApplication\Student.mdf;Integrated Security=True;User Instance=True") conStudent.Open() Try commStudent = New SqlClient.SqlCommand(SQL, conStudent) commStudent.ExecuteNonQuery() MsgBox("Itemdeleted successfully", MsgBoxStyle.Information) Catch ex As Exception MsgBox(ex.Message) End Try conStudent.Close() conStudent.Dispose() Else Exit Sub End If End Sub any help :confused: waiting for your kind rep. have a nice time thanks

          M Offline
          M Offline
          mrcsn
          wrote on last edited by
          #4

          hi , in try block after query exection just assign textbox.text=""; i think this solves u r problem . if this is in webapplication we can set viewstate as false . bye .

          B 1 Reply Last reply
          0
          • M mrcsn

            hi , in try block after query exection just assign textbox.text=""; i think this solves u r problem . if this is in webapplication we can set viewstate as false . bye .

            B Offline
            B Offline
            bapu2889
            wrote on last edited by
            #5

            hello thansk for your kind rep. yes i have tried that before but it's not working well it's clear the text box but it also shows empty textbox when you move next or previous so i dont know what to do still waiting for help :confused: :zzz: have a nice day

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups