Insert records using VB in Visual Studio .NET 2003

Insert records using VB in Visual Studio .NET 2003

Postby wrighty » Thu 05 Jan 2006 11:47

Hi

I'm trying to use VB in VS.NET 2003 to iput data from a PDA to a MySQL database.

Could someone give an example of how to do this please.

Thanks
wrighty
 
Posts: 6
Joined: Wed 05 Oct 2005 13:00

Postby Serious » Thu 05 Jan 2006 13:20

If you use MySQLDirect .NET and want to Insert/Update/Delete rows in database table with Pocket PC you can use the same technicue as in common Windows application.

Some limitations are caused by controls restrictions in .NET Compact Framework. For instance, DataGrid component does not allow data modifications. Use custom dialogs in this case.
Serious
 

Error trying to insert data

Postby wrighty » Thu 05 Jan 2006 16:10

I get the following error

An unhandled exception of type 'System.ArgumentException' occurred in CoreLab.MySql.dll

Additional information: ParameterValueMissing

on this line

Dim myConnection As New MySqlConnection(myConnectionString)

myConnectionString isset as
myConnectionString = "Database=mysqldb;Data Source=localhost;User Id=root;Password="

The full code is

Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
' If the connection string is null, use a default.
If myConnectionString = "" Then
myConnectionString = "Database=mysqldb;Data Source=localhost;User Id=root;Password="
End If
Dim myConnection As New MySqlConnection(myConnectionString)
Dim myInsertQuery As String = "INSERT INTO test_table (Name, Telephone, Job) Values('" & TxtName.Text & "', '" & TxtTelephone.Text & "', '" & TxtJob.Text & "')"
Dim myCommand As New MySqlCommand(myInsertQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.Close()
Close()
End Sub

Help please
wrighty
 
Posts: 6
Joined: Wed 05 Oct 2005 13:00

Postby Serious » Thu 05 Jan 2006 16:32

You shouldn't use "Password" connection parameter if your MySQL database account has no password.
Valid connection string in this case: "Database=mysqldb;Data Source=localhost;User Id=root;"
Therefore this exception is a bug in MySQLDirect .NET. We'll fix it in the next build.
Serious
 


Return to dotConnect for MySQL