Kartik Mayya

Kartik Mayya

  • NA
  • 1
  • 887

sudent management application

Mar 24 2016 7:33 AM
im writing an application to store the details of the student in a database.im using visual studio 2012 and writing in it windows forms application.
the problem is that im trying to insert the data to the database table i've created.but the data is not showing in the table.the code runs fine with no errors.also the inserted data is getting displayed in the message box.    
please help to make the data appear in the data table i've created.
 
Imports System.Data.SqlServerCe
Public Class Form10
Private Sub SAVE_Click(sender As Object, e As EventArgs) Handles SAVE.Click
Dim studentname As String
Dim r As Integer
r = 0
studentname = TextBox1.Text
Dim connection As SqlCeConnection
Dim cmdString = "INSERT INTO [student](studentname) values('" & studentname & "')"
Dim cmdString1 = "select * from student"
connection = New SqlCeConnection("Data Source=gandharva.sdf")
connection.Open()
Dim command As SqlCeCommand
Dim command1 As SqlCeCommand
command = New SqlCeCommand(cmdString1, connection)
command1 = New SqlCeCommand(cmdString, connection)
command.ExecuteNonQuery()
r = command1.ExecuteNonQuery()
Dim reader As SqlCeDataReader
reader = command.ExecuteReader(CommandBehavior.CloseConnection)
Dim stdpaswd As String
While reader.Read()
stdpaswd = reader("studentname").ToString()
MsgBox(stdpaswd)
End While
connection.Close()
End Sub
End Class
 
the table is like this
 
studentname
 
kartik
abhi
NULL 
 
 
 
 
 
 

Answers (1)