Insert Statement Creating NULL Rows???
Posted by: Jackie Apshire
Date: February 11, 2005 11:17AM

Can anyone explain to me why this insert statement is inserting NULL values into my MySQL Database. What I'm doing is pulling information from a FoxPro Table and trying to insert them into MySQL. I know that the dataset contains the needed information and that the rowstate is 4.

--------------------------------------------------------------------------------


Dim vfSQL As String = "SELECT * FROM mysqltest"

Dim conStr As String = "Provider=VFPOLEDB.1;DATA Source=Data;Mode=Share Deny None;Extended Properties=;Encrypt Password=False"

Dim vfCon As New OleDb.OleDbConnection(conStr)

Dim vfDA As New OleDb.OleDbDataAdapter(vfSQL, vfCon)

Dim vfDS As New DataSet

vfDA.AcceptChangesDuringFill = False

vfDA.Fill(vfDS, "mysqltest")



Dim mSQL As String = "SELECT * FROM mysqltest"

conStr = "Persist Security Info=False;database=DDMS;server=localhost;user id=manweb;Password=SQL4144mSs"

Dim mCon As New MySql.Data.MySqlClient.MySqlConnection(conStr)

Dim mDA As New MySql.Data.MySqlClient.MySqlDataAdapter(mSQL, mCon)



mDA.TableMappings.Add("mysqltest", "mysqltest")



Dim iCmd As MySql.Data.MySqlClient.MySqlCommand

iCmd = New MySql.Data.MySqlClient.MySqlCommand("INSERT INTO mysqltest(`fName`, `lName`, `Address`, `City`, `zip`, `state`) VALUE (@fName, @lName, @Address, @City, @Zip, @State)", mCon)

iCmd.Parameters.Add(New MySql.Data.MySqlClient.MySqlParameter("@fName", MySql.Data.MySqlClient.MySqlDbType.VarChar, 10, "fName"))

iCmd.Parameters.Add(New MySql.Data.MySqlClient.MySqlParameter("@lName", MySql.Data.MySqlClient.MySqlDbType.VarChar, 10, "lName"))

iCmd.Parameters.Add(New MySql.Data.MySqlClient.MySqlParameter("@Address", MySql.Data.MySqlClient.MySqlDbType.VarChar, 30, "Address"))

iCmd.Parameters.Add(New MySql.Data.MySqlClient.MySqlParameter("@City", MySql.Data.MySqlClient.MySqlDbType.VarChar, 10, "City"))

iCmd.Parameters.Add(New MySql.Data.MySqlClient.MySqlParameter("@Zip", MySql.Data.MySqlClient.MySqlDbType.Int16, 5, "Zip"))

iCmd.Parameters.Add(New MySql.Data.MySqlClient.MySqlParameter("@state", MySql.Data.MySqlClient.MySqlDbType.VarChar, 2, "state"))

mDA.InsertCommand = iCmd



Response.Write("RowState = " & vfDS.Tables("mysqltest").Rows(0).RowState() & "<br>First Name: " & vfDS.Tables("mysqltest").Rows(0).Item(1))

mDA.Update(vfDS, "mysqltest")



Dim myDS As New DataSet

mDA.Fill(myDS, "mysqltest")

Options: ReplyQuote


Subject
Written By
Posted
Insert Statement Creating NULL Rows???
February 11, 2005 11:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.