<html><div style='background-color:'><DIV class=RTE>Hi</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>I am having problems with the NpgsqlDataAdapter. I created an insert command and when I call the update method, I get an error: ERROR: 42601: syntax error at or near":"</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>If I remove some of the columns from the insert statement, it works. It seems like there is a limit to the length of the command text.</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>I am using C# 2003 (.NET Framework 1.1) on Windowx XP.</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>I create the data adapter using the following code:</DIV><FONT size=2>
<P class=RTE></FONT><FONT color=#0000ff size=2>string</FONT><FONT size=2> poSelect = "SELECT po_number, supplier, originated_by, deliver_to, " +</FONT></P>
<P class=RTE><FONT size=2>"po_status_code, shipping_company, ship_point, service_order, " +</P>
<P class=RTE>"fob, freight, internal_comments, external_comments, currency, " +</P>
<P class=RTE>"hide_cost_on_printout " +</P>
<P class=RTE>"FROM purchase_order";</P>
<P class=RTE>m_daPO = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlDataAdapter(poSelect, m_posDBConn);</P>
<P class=RTE></FONT><FONT color=#0000ff size=2>string</FONT><FONT size=2> poInsert = "INSERT INTO purchase_order (po_number, supplier, currency, " +</P>
<P class=RTE>"originated_by, deliver_to, po_status_code, shipping_company, fob, freight, " +</P>
<P class=RTE>"internal_comments, external_comments, service_order, hide_cost_on_printout) " +</P>
<P class=RTE>"VALUES (:po_number, :supplier, :currency, " +</P>
<P class=RTE>":originated_by, :deliver_to, :po_status_code, :shipping_company, :fob, :freight, " +</P>
<P class=RTE>":internal_comments, :external_comments, service_order, :hide_cost_on_printout)";</P>
<P class=RTE>NpgsqlCommand poInsertCmd = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlCommand(poInsert, m_posDBConn);</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("po_number", DbType.Int16));</P>
<P class=RTE>poInsertCmd.Parameters["po_number"].SourceColumn = "po_number";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("supplier", DbType.Int16));</P>
<P class=RTE>poInsertCmd.Parameters["supplier"].SourceColumn = "supplier";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("currency", DbType.String));</P>
<P class=RTE>poInsertCmd.Parameters["currency"].SourceColumn = "currency";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("originated_by", DbType.Int16));</P>
<P class=RTE>poInsertCmd.Parameters["originated_by"].SourceColumn = "originated_by";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("deliver_to", DbType.Int16));</P>
<P class=RTE>poInsertCmd.Parameters["deliver_to"].SourceColumn = "deliver_to";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("po_status_code", DbType.Int16));</P>
<P class=RTE>poInsertCmd.Parameters["po_status_code"].SourceColumn = "po_status_code";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("shipping_company", DbType.Int16));</P>
<P class=RTE>poInsertCmd.Parameters["shipping_company"].SourceColumn = "shipping_company";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("freight", DbType.String));</P>
<P class=RTE>poInsertCmd.Parameters["freight"].SourceColumn = "freight";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("fob", DbType.String));</P>
<P class=RTE>poInsertCmd.Parameters["fob"].SourceColumn = "fob";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("internal_comments", DbType.String));</P>
<P class=RTE>poInsertCmd.Parameters["internal_comments"].SourceColumn = "internal_comments";</P>
<P class=RTE>poInsertCmd.Parameters.Add(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> NpgsqlParameter("external_comments", DbType.String));</P>
<P class=RTE>poInsertCmd.Parameters["external_comments"].SourceColumn = "external_comments";</P>
<P class=RTE>m_daPO.InsertCommand = poInsertCmd;</P>
<P class=RTE> </P>
<P class=RTE>After that I load the data using the Fill method of the data adapter. Then a new row is inserted into the "po" DataTable. I check the DataSet and the row has been added.</P>
<P class=RTE>Then I save the data. Here is first part of the code for the update:</P><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>try</P></FONT><FONT size=2>
<P>{</P>
<P>m_posDBConn.Open();</P>
<P>poUpdate = m_posDBConn.BeginTransaction();</P>
<P>m_daPO.InsertCommand.Transaction = poUpdate;</P>
<P></FONT><FONT color=#0000ff size=2>try</P></FONT><FONT size=2>
<P>{</P>
<P>m_daPO.Update(m_dsPO, "po"); // this causes error</P>
<P>poUpdate.Commit();</P></FONT>
<P class=RTE>...</P>
<P class=RTE> </P>
<P class=RTE>I would appreciate help with this as soon as possible because it is impeding development.</P>
<P class=RTE>Thanks.</P>
<P class=RTE>Evan</P>
<P class=RTE> </P></FONT></div></html>