mymuji 0 Newbie Poster

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
---------

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
----------

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
----------

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()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.