Problem to insert data for mobile device

mymuji

New member
Joined
Sep 4, 2008
Messages
1
Programming Experience
1-3
I have created a small application for mobile device using vs2008.

i can retrieve the data . But i cant insert the data's into the database.

These are methods i used to insert. But no work

Any one can help to solve this issue.

Method - 1
VB.NET:
        Dim conn As New SqlCeConnection("Data Source=\Program Files\SmartDeviceProject8\11.sdf")
        conn.Open()
        Dim sqlstring As String = "insert into tblTest(EmpName) values(@EmpName)"
        Dim cmnd As SqlCeCommand = New SqlCeCommand(sqlstring, conn)
        Dim myname As String = "abcdef"
        cmnd.Parameters.AddWithValue("@EmpName", myname)
        cmnd.ExecuteNonQuery()
        conn.Close()

Method - 2
VB.NET:
        Dim conn As New SqlCeConnection("Data Source=\Program Files\SmartDeviceProject8\11.sdf")
        Dim sqlstring As String = "insert into tblTest(EmpName) values('abcdef')"
        Dim concom As SqlCeCommand = conn.CreateCommand()
        conn.Open()
        Dim cmnd As SqlCeCommand = New SqlCeCommand(sqlstring, conn)
        cmnd.ExecuteNonQuery()
        Dim myreader As SqlCeDataReader
        myreader = cmnd.ExecuteReader
        conn.Close()

Method - 3
VB.NET:
	Dim conn As New SqlCeConnection("Data Source=\Program Files\SmartDeviceProject8\11.sdf")
        conn.Open()
        Dim qry As String = "insert into tblTest(EmpName) values('abcdef')"
        Dim cmd As SqlCeCommand = conn.CreateCommand()
        cmd.CommandType = CommandType.Text       
        cmd.CommandText = qry
        cmd.ExecuteNonQuery()
	conn.Close()
 
Last edited by a moderator:
Back
Top