i have written this code to inser data in my database table "member "through the form but it is not working if i start debugging the code it gives no error but when i open my database table to see the inserted data it is not working.
please help me to do this succesfully.
Imports System.Data.SqlClient
Public Class Form3
Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If con.State = ConnectionState.Open Then
con.Close()
End If
Try
If RichTextBox1.Text.Length = 0 Then
MsgBox("MemId field cannot be empty insert value")
Else
con.Open()
Dim instr As String = "INSERT INTO member VALUES('" + RichTextBox1.Text + "','" + RichTextBox2.Text + "','" + RichTextBox3.Text + "','" + RichTextBox4.Text + "','" + RichTextBox5.Text + "','" + RichTextBox6.Text + "')"
Dim cmd As New SqlCommand(instr, con)
MsgBox("Database connected successfully")
Dim rdr = cmd.ExecuteReader()
If rdr.HasRows Then
Label8.Text = "*Record created successfully*"
cmd.Dispose()
End If
rdr.Close()
cmd.Dispose()
End If
Catch ex As Exception
MsgBox(ex.Message)
con.Close()
End Try
End Sub