•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 456,485 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,780 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 4781 | Replies: 8
![]() |
•
•
Join Date: Sep 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I am currently developing an application using vb.net 2005 and windows mobile 6 sdk,and sql server ce for my database.
I try to connect to the database i created using the following code: I get an identifier expected error
pointing the dot[.] .The code is this
Visual Basic.Net 2005. The whole class is the following:
I am currently developing an application using vb.net 2005 and windows mobile 6 sdk,and sql server ce for my database.
I try to connect to the database i created using the following code: I get an identifier expected error
pointing the dot[.] .The code is this
("Data Source =".\ MyDatabase.sdf;"")Visual Basic.Net 2005. The whole class is the following:
Dim conn As SqlCeConnection = Nothing
Try
conn = New SqlCeConnection("Data Source =".\ MyDatabase.sdf;"")
conn.Open()
Dim cmd As SqlCeCommand = conn.CreateCommand()
cmd.CommandText = "INSERT INTO Customers (Customerid], Name) Values('9', 'Smith')"
cmd.ExecuteNonQuery()
Finally
conn.Close()
End Try Hi
I think the problem is that the syntax of your command is wrong.
You have:
it should be:
I use this and it works.
Hope it helps
I think the problem is that the syntax of your command is wrong.
You have:
conn = New SqlCeConnection("Data Source =".\ MyDatabase.sdf;"")it should be:
conn = New SqlCeConnection("Data Source =.\ MyDatabase.sdf")I use this and it works.
dim data_base As String = "\Program Files\My App\MyDB.sdf"
dim dap As SqlCeDataAdapter = New SqlCeDataAdapter
dim conn As SqlCeConnection = New SqlCeConnection("Data Source=" & data_base)
dim cmnd As SqlCeCommand = New SqlCeCommand("SELECT FROM table", conn)
conn.open()
...
Hope it helps
•
•
Join Date: Sep 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Hi, Thank you . Now the path seems to work. The other problem is I cant add data to the database.
The code I use is:
Thanks again.
The code I use is:
Dim MyConnection As SqlCeConnection
Dim sqlstring As String = "INSERT INTO Titles VALUES ('2','1','0')"
Dim data_base As String = "\Program Files\vbdata\vbdata.sdf"
MyConnection = New SqlCeConnection("Data Source=" & data_base)
Dim concom As SqlCeCommand = MyConnection.CreateCommand()
Dim cmnd As SqlCeCommand = New SqlCeCommand(sqlstring, MyConnection)
Dim myreader As SqlCeDataReader
MyConnection.Open()
myreader = cmnd.ExecuteReader
MyConnection.Close()Thanks again.
Last edited by SGiorgos : Sep 14th, 2007 at 1:34 pm. Reason: edit to reveal code
Hi
your code is not executing the command (i think); try this:
your code is not executing the command (i think); try this:
Dim MyConnection As SqlCeConnection
Dim sqlstring As String = "INSERT INTO Titles VALUES ('2','1','0')"
Dim data_base As String = "\Program Files\vbdata\vbdata.sdf"
MyConnection = New SqlCeConnection("Data Source=" & data_base)
Dim concom As SqlCeCommand = MyConnection.CreateCommand()
MyConnection.Open()
Dim cmnd As SqlCeCommand = New SqlCeCommand(sqlstring, MyConnection)
cmnd.ExecuteNonQuery() ' Execute the command here
'and then read
Dim myreader As SqlCeDataReader
myreader = cmnd.ExecuteReader
MyConnection.Close()
Hi
I just noticed that you are missing the field names in the sql command, you have:
and it should be:
I just tried it on my PPC and it works. I also noticed that you the command specifies all the values as strings, but they are numbers. Make sure you input the values in the right format, otherwise you might have an error.
I just noticed that you are missing the field names in the sql command, you have:
Dim sqlstring As String = "INSERT INTO Titles VALUES ('2','1','0')"Dim sqlstring As String = "INSERT INTO Titles(fileld0, field1, field2) VALUES ('2','1','0')"I just tried it on my PPC and it works. I also noticed that you the command specifies all the values as strings, but they are numbers. Make sure you input the values in the right format, otherwise you might have an error.
•
•
Join Date: Sep 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
thnx a lot, everything is working like a charm 
The net thing now is how to query the emulators database :p ( i mean through visual basic query manager ) . Because when i insert data through the emulator and then close the emulator the database is not stored anywhere .
thnx again

The net thing now is how to query the emulators database :p ( i mean through visual basic query manager ) . Because when i insert data through the emulator and then close the emulator the database is not stored anywhere .
thnx again
Last edited by SGiorgos : Sep 17th, 2007 at 3:15 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
apple blackberry browser cellphone computer crack daniweb database dell development google government hardware install internet ipod laptop leopard license linux microsoft mobile news open operating operating system os pda photo power research security server software sony source survey system technology telephony ubuntu unix upgrade virus vista web windows windows update windows vista xp
- How to connect MSAccess database in ASP.NET (C#)
- How to connect Oracle database from JSP page (Java)
- Updating a record in an MS Access database file using DataSets (VB.NET)
- Windows Mobile & Datagrid (VB.NET)
- how to connect oracle 8i database with jsp page (JSP)
- WinSock & Windows Mobile 5 (C++)
- shortcut on client to connect to remote database filemaker (MS Access and FileMaker Pro)
- 62.214.197.166 wants to send email through java (Viruses, Spyware and other Nasties)
- how willl i be able to save a specific record into my database file in ms access (Java)
Other Threads in the VB.NET Forum
- Previous Thread: > mini project advice and suggestion needed on how to start it
- Next Thread: remove failed image.


Linear Mode