List:MySQL and .NET« Previous MessageNext Message »
From:Reggie Burnett Date:October 28 2004 5:48pm
Subject:RE: Broken Code
View as plain text  
Joshua

The test suite includes many tests using parameterized inserts and some
tests for using old syntax.  Can you post a short snippet of what you are
trying to do?

-reggie

> -----Original Message-----
> From: Joshua Mouch [mailto:joshua@stripped]
> Sent: Thursday, October 28, 2004 11:38 AM
> To: 'Joshua Mouch'; dotnet@stripped
> Subject: RE: Broken Code
> 
> Spoke too soon again. :-)  While this does get rid of the exception, it
> inserts a "blank" row into the database (e.g. null values or zeros or
> default values for all of the columns).
> 
> Does anybody have a working insert that uses parameters?  Surely this
> should
> be working. :-)
> 
> Joshua Mouch
> EmailScout Support Team
> http://www.emailscout.net
> 
> 
> -----Original Message-----
> From: Joshua Mouch [mailto:joshua@stripped]
> Sent: Thursday, October 28, 2004 12:19 PM
> To: dotnet@stripped
> Subject: RE: Broken Code
> 
> Okay, it seems that the problem is that when you add a parameter, the "@"
> is
> stripped from the name.
> 
> So,
> cmd.parameters.add("@ParamName", "Value")
> actually creates a parameter called "ParamName", not "@ParamName".
> 
> So, I removed all of the @'s from my SQL query (to account for the above
> behavior) and it started working.
> 
> Joshua Mouch
> EmailScout Support Team
> http://www.emailscout.net
> 
> 
> -----Original Message-----
> From: Joshua Mouch [mailto:joshua@stripped]
> Sent: Thursday, October 28, 2004 11:50 AM
> To: dotnet@stripped
> Subject: RE: Broken Code
> 
> I guess I jumped to conclusions on my last post.  Adding an @ symbol to
> the
> parameter names doesn't seem to help.  Here's my test case:
> 
>         Dim sqlStr As String = "INSERT INTO schools (" + _
>             "EntityNumber, " + _
>             "SchoolName, " + _
>             "Address, " + _
>             "City, " + _
>             "State, " + _
>             "Zip, " + _
>             "IsClient, " + _
>             "DateTime, " + _
>             "PrimaryContactID" + _
>             ") VALUES (" + _
>             "@EntityNumber" + ", " + _
>             "@SchoolName" + ", " + _
>             "@Address" + ", " + _
>             "@City" + ", " + _
>             "@State" + ", " + _
>             "@Zip" + ", " + _
>             "@IsClient" + ", " + _
>             "@DateTime" + ", " + _
>             "@PrimaryContactID" + ");SELECT @@IDENTITY"
> 
>         Dim cmd As MySqlCommand = New MySqlCommand(sqlStr,
> DatabaseManager.db.Connection)
>         cmd.Parameters.Add("@EntityNumber", "TEST")
>         cmd.Parameters.Add("@SchoolName", "TEST")  ' tried "SchoolName"
>         cmd.Parameters.Add("@Address", "TEST")
>         cmd.Parameters.Add("@City", "TEST")
>         cmd.Parameters.Add("@State", "TEST")
>         cmd.Parameters.Add("@Zip", "TEST")
>         cmd.Parameters.Add("@IsClient", False)
>         cmd.Parameters.Add("@DateTime", Now)
>         cmd.Parameters.Add("@PrimaryContactID", 0)
>         Dim SchoolID As Integer = Convert.ToInt32(cmd.ExecuteScalar())
> 
> The very last line throws a "Column 'SchoolName' cannot be null"
> exception.
> I tried with and without the @ signs when adding parameters to the
> command.
> 
> Joshua Mouch
> EmailScout Support Team
> http://www.emailscout.net
> 
> 
> -----Original Message-----
> From: Barry Zubel [mailto:barry@stripped]
> Sent: Thursday, October 28, 2004 11:36 AM
> To: dotnet@stripped
> Subject: RE: Broken Code
> 
> Are you sure you're looking at the source for Beta 1.0.1?
> 
> Within 'ConnectionString.cs' at Ln 320:
> 
> 				defaults["oldsyntax"] = false;
> 
> Certainly works if I turn it on here?
> 
> B.
> 
> -----Original Message-----
> From: Darren Hill [mailto:darren@stripped]
> Sent: 28 October 2004 16:13
> To: dotnet@stripped
> Subject: RE: Broken Code
> 
> 
> Looking in the source, there's no such keyword.
> 
> Darren Hill
> darren@stripped
> Tel: 416-410-1154 ext. 2
> Toll Free: 866-410-1154 ext. 2
> Fax: 905-873-6685
> 
> 
> -----Original Message-----
> From: Darren Hill [mailto:darren@stripped]
> Sent: October 28, 2004 11:00 AM
> To: dotnet@stripped
> Subject: RE: Broken Code
> 
> I get a Keyword not supported: 'oldsyntax' when I try to do that.
> 
> oldsyntax=true;
> 
> Darren Hill
> darren@stripped
> Tel: 416-410-1154 ext. 2
> Toll Free: 866-410-1154 ext. 2
> Fax: 905-873-6685
> 
> 
> -----Original Message-----
> From: Barry Zubel [mailto:barry@stripped]
> Sent: October 28, 2004 10:53 AM
> To: 'Joshua Mouch'; dotnet@stripped
> Subject: RE: Broken Code
> 
> Enter 'oldsyntax=true' in your connection string.
> 
> Syntax changed from @ to ? for parameter identification in beta 1.
> 
> Ideally, replace the @'s with ?'s in your code, but for the moment,
> oldsyntax=true will override this within the driver.
> 
> B.
> 
> -----Original Message-----
> From: Joshua Mouch [mailto:joshua@stripped]
> Sent: 28 October 2004 15:48
> To: dotnet@stripped
> Subject: Broken Code
> 
> 
> I just dropped in the new DLL.  Previously I was using version .76, and
> this
> is what I came across.
> 
> You used to be able to declare a command similar to:
> 
> Dim cmd as new mysqlcommand("INSERT INTO Table (VAR1) VALUES (@Var1)")
> 
> And then add a parameter called "Var1" and it would work.  It looks like
> you
> now have to add a parameter called "@Var1".
> 
> This is likely by design, and it isn't a big deal except that my code
> generator doesn't do that (RapTier)... guess it's time to switch to a new
> code gen.  :)
> 
> Joshua Mouch
> EmailScout Support Team
> http://www.emailscout.net
> 
> 
> -----Original Message-----
> From: Barry Zubel [mailto:barry@stripped]
> Sent: Thursday, October 28, 2004 10:27 AM
> To: 'Barry Zubel'; dotnet@stripped
> Subject: Only byte arrays can be serialized by MySqlBinary
> 
> "Only byte arrays can be serialized by MySqlBinary"
> 
> Okay - Without delving too deep into the code yet (I've simply dropped the
> new Mysql.Data.Dll into our existing package and tried a few things) I'm
> getting this error when attempting to .Update a datatable.
> 
> Some sample code as follows:
> 
> 	Public Function Save(ByVal spec As Spec) As Boolean
> 
> 		Dim sSql As String
> 		sSql = "SELECT * FROM S_SPEC WHERE EN_NO=" & spec.ENNO
> 
> 		Dim conn As New
> MySqlConnection(APDApp.MySql.ConnectionString)
> 		conn.Open()
> 		Dim comm As New MySqlCommand(sSql, conn)
> 		Dim rs As New MySqlDataAdapter(comm)
> 		Dim cb As New MySqlCommandBuilder(rs)
> 		Dim dt As New DataTable
> 		rs.Fill(dt)
> 
> 		Dim bIsNew As Boolean = False
> 		Dim row As DataRow
> 		If dt.Rows.Count = 0 Then
> 			' does not exist, so create
> 			row = dt.NewRow
> 			bIsNew = True
> 		Else
> 			row = dt.Rows(0)
> 			bIsNew = False
> 		End If
> 
> 		row("C_NO") = spec.CNO
> 		row("B_MAT") = spec.BMat
> 		row("CUSTOMER") = spec.Customer
> 		row("CUSTREF1") = spec.CustRef1
> 		row("CUSTREF2") = spec.CustRef2
> 		row("DEPTH") = spec.Depth
> 		row("EN_DATE") = spec.ENDate
> 		row("FEFCO") = spec.Fefco
> 		row("JOINTYPE") = spec.Join
> 		row("LENGTH") = spec.Length
> 		row("S_MEMO") = spec.Memo
> 		row("PRINT") = spec.Print
> 		row("QUALITY") = spec.Quality
> 		row("STYLE") = spec.Style
> 		row("WIDTH") = spec.Width
> 		row("DELNOTE") = spec.DelNote
> 
> 		If bIsNew Then
> 			dt.Rows.Add(row)
> 		End If
> 
> 		rs.Update(dt)
> 
> 		dt.Dispose()
> 		rs.Dispose()
> 		cb.Dispose()
> 		comm.Dispose()
> 		conn.Close()
> 		conn.Dispose()
> 
> 	End Function
> 
> --- Table Structure ---
> 
> CREATE TABLE `apdwin`.`s_spec` (
> `ID` int( 11 ) NOT NULL AUTO_INCREMENT ,
> `EN_NO` int( 6 ) NOT NULL default '0',
> `CLEAN` double NOT NULL default '0',
> `C_NO` smallint( 6 ) NOT NULL default '0',
> `CUSTOMER` varchar( 50 ) NOT NULL default '',
> `EN_DATE` date default NULL ,
> `CUSTREF1` varchar( 30 ) NOT NULL default '',
> `CUSTREF2` varchar( 30 ) NOT NULL default '',
> `B_MAT` char( 3 ) NOT NULL default '',
> `QUALITY` varchar( 30 ) NOT NULL default '',
> `FEFCO` varchar( 6 ) NOT NULL default '',
> `STYLE` varchar( 30 ) NOT NULL default '',
> `JOINTYPE` char( 1 ) NOT NULL default '',
> `LENGTH` smallint( 6 ) NOT NULL default '0',
> `WIDTH` smallint( 6 ) NOT NULL default '0',
> `DEPTH` smallint( 6 ) NOT NULL default '0',
> `STOCK` double NOT NULL default '0',
> `GRAMS` double NOT NULL default '0',
> `BAND` char( 1 ) NOT NULL default '',
> `PRINT` char( 2 ) NOT NULL default '',
> `EQPAL` double NOT NULL default '0',
> `PREV_ENNO` double NOT NULL default '0',
> `DELNOTE` varchar( 255 ) NOT NULL default '',
> `S_MEMO` mediumtext NOT NULL ,
> `DEL_ADD_ID` int( 11 ) NOT NULL default '0',
> PRIMARY KEY ( `ID` ) ,
> UNIQUE KEY `en_no` ( `EN_NO` ) ,
> KEY `c_no` ( `C_NO` ) ,
> KEY `clean` ( `CLEAN` ) ,
> KEY `customer` ( `CUSTOMER` ) ,
> KEY `custref1` ( `CUSTREF1` ) ,
> ) TYPE = InnoDB PACK_KEYS =1;
> 
> Any ideas, off the top of your head Reggie?
> 
> B.
> 
> -----Original Message-----
> From: Barry Zubel [mailto:barry@stripped]
> Sent: 28 October 2004 14:52
> To: dotnet@stripped
> Subject: RE: MySQL Connector/Net 1.0.1 beta 2 has been released.
> 
> 
> For those of you slowly working through the mirror sites to find one that
> works, this one appears to:
> 
> http://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-1.0
> .1-b
> eta.zip/from/http://mysql.mirrors.pair.com/
> 
> Off to unzip and try it!
> 
> Thanks Reggie! :D
> 
> B.
> 
> -----Original Message-----
> From: Reggie Burnett [mailto:reggie@stripped]
> Sent: 28 October 2004 14:28
> To: announce@stripped; dotnet@stripped
> Subject: MySQL Connector/Net 1.0.1 beta 2 has been released.
> 
> 
> Hi,
> 
> MySQL Connector/Net 1.0.1, a new version of the fully-managed, ADO.Net
> provider for the popular MySQL database system.
> 
> Version 1.0.1 is the second beta release of the original ByteFX MySQL
> provider acquired earlier this year.  This release is suitable for use
> with
> any MySQL version including MySQL-4.1 or MySQL-5.0.
> 
> It is now available in source and binary form from the Connector/Net
> download pages at http://dev.mysql.com/downloads/connector/net/1.0.html
> and mirror sites (note that not all mirror sites may be up to date at this
> point of time - if you can't find this version on some mirror, please try
> again later or choose another download site.)
> 
> ========================= Attention ======================================
> During the final QA process for 1.0.1, a problem was discovered where data
> packets larger than 16M are not handled properly when the connection is
> using compression.  There is no need to file bug reports on this issue as
> the test suite already identifies this as a problem.
> ========================================================================
> ==
> 
> -Reggie
> 
> 
> - From the changelog:
> 
> 10-25-04 - Version 1.0.1-beta
> 
>     - Fixed BUG #5602 Possible bug in MySqlParameter(string, object)
> constructor
>     - Fixed BUG #5458 Calling GetChars on a longtext column throws an
> exception
>     - Fixed BUG #5474 cannot run a stored procedure populating
> mysqlcommand.parameters
>     - Fixed BUG #5469 Setting DbType throws NullReferenceException
>     - Fixed problem where connector was not issuing a CMD_QUIT before
> closing the socket
> 	- Fixed BUG #5392 MySqlCommand sees "?" as parameters in string
> literals
>     - Fixed problem with ConnectionInternal where a key might be added
> more
> than once
>     - CP1252 is now used for Latin1 only when the server is 4.1.2 and
> later
>     - Fixed BUG #5388 DataReader reports all rows as NULL if one row is
> NULL
> 	- Virtualized driver subsystem so future releases could easily
> support client or embedded server support
> 	- Field buffers being reused to decrease memory allocations and
> increase speed
> 	- Fixed problem where using old syntax while using the interfaces
> caused problems
> 	- Using PacketWriter instead of Packet for writing to streams
> 	- Refactored compression code into CompressedStream to clean up
> NativeDriver
> 	- Added test case for resetting the command text on a prepared
> command
> 	- Fixed problem where MySqlParameterCollection.Add() would throw
> unclear exception when given a null value (Bug #5621)
> 	- Fixed construtor initialize problems in MySqlCommand() (Bug
> #5613)
> 	- Fixed Parsing the ';' char (Bug #5876)
> 	- Fixed missing Reference in DbType setter (Bug #5897)
> 	- Fixed System.OverflowException when using YEAR datatype (Bug
> #6036)
> 	- Added Aggregate function test (wasn't really a bug)
> 	- Fixed serializing of floating point parameters (double, numeric,
> single, decimal) (Bug #5900)
> 	- IsNullable error (Bug #5796)
> 	- Fixed problem where connection lifetime on the connect string was
> not being respected
> 	- Fixed problem where Min Pool Size was not being respected
> 	- Fixed MySqlDataReader and 'show tables from ...' behaviour (Bug
> #5256)
> 	- Implemented SequentialAccess
> 	- Fixed MySqlDateTime sets IsZero property on all subseq.records
> after first zero found (Bug #6006)
> 	- Fixed Can't display Chinese correctly (Bug #5288)
> 	- Fixed Russian character support as well
> 	- Fixed Method TokenizeSql() uses only a limited set of valid
> characters for parameters (Bug #6217)
> 	- Fixed NET Connector source missing resx files (Bug #6216)
> 	- Fixed DBNull Values causing problems with retrieving/updating
> queries. (Bug #5798)
> 	- Fixed Yet Another "object reference not set to an instance of an
> object" (Bug #5496)
> 	- Fixed problem in PacketReader where it could try to allocate the
> wrong buffer size in EnsureCapacity
> 	- Fixed GetBoolean returns wrong values (Bug #6227)
> 	- Fixed IndexOutOfBounds when reading BLOB with DataReader with
> GetString(index) (Bug #6230)
> 
> Reggie Burnett, Software Developer
> MySQL Inc, http://www.mysql.com
> 
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:    http://lists.mysql.com/dotnet?unsub=1
> 
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:    http://lists.mysql.com/dotnet?unsub=1
> 
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe: http://lists.mysql.com/dotnet?unsub=1
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:    http://lists.mysql.com/dotnet?unsub=1
> 
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:    http://lists.mysql.com/dotnet?unsub=1
> 
> 
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:    http://lists.mysql.com/dotnet?unsub=1
> 
> 
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:    http://lists.mysql.com/dotnet?unsub=1
> 
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:
> http://lists.mysql.com/dotnet?unsub=1
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:
> http://lists.mysql.com/dotnet?unsub=1
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:
> http://lists.mysql.com/dotnet?unsub=1
> 
> 
> --
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe:    http://lists.mysql.com/dotnet?unsub=1

Thread
DataAdapter Update and ConnectionFrank23 Nov
  • RE: MySQL Connector/Net 1.0.1 beta 2 has been released.Barry Zubel28 Oct
    • Only byte arrays can be serialized by MySqlBinaryBarry Zubel28 Oct
      • Broken CodeJoshua Mouch28 Oct
        • RE: Broken CodeBarry Zubel28 Oct
          • RE: Broken CodeDarren Hill28 Oct
            • RE: Broken CodeDarren Hill28 Oct
              • RE: Broken CodeBarry Zubel28 Oct
                • RE: Broken CodeDarren Hill28 Oct
                  • RE: Broken CodeBarry Zubel28 Oct
                    • RE: Broken CodeDarren Hill28 Oct
                    • RE: Broken CodeJoshua Mouch28 Oct
                  • RE: Broken CodeReggie Burnett28 Oct
                • RE: Broken CodeJoshua Mouch28 Oct
                  • RE: Broken CodeJoshua Mouch28 Oct
                    • RE: Broken CodeJoshua Mouch28 Oct
                      • RE: Broken CodeReggie Burnett28 Oct
      • RE: Only byte arrays can be serialized by MySqlBinaryReggie Burnett28 Oct
        • An established connection was aborted by the software in your host machineDarren Hill3 Nov
      • RE: Only byte arrays can be serialized by MySqlBinaryBarry Zubel28 Oct
        • RE: Only byte arrays can be serialized by MySqlBinaryReggie Burnett28 Oct
        • RE: Only byte arrays can be serialized by MySqlBinaryReggie Burnett28 Oct