Date: 01/09/06 (C Sharp) Keywords: database, sql Okay, I'm stumped. private void btnSave_Click(object sender, EventArgs e) { try { string InsertString = "INSERT INTO Erasmus.Publisher(Name, PublisherURL) VALUES(@Name,@URL)"; ErasmusTransaction = ErasmusConnection.BeginTransaction(IsolationLevel.ReadCommitted); ErasmusInsertCommand = new OdbcCommand(InsertString, ErasmusConnection, ErasmusTransaction); OdbcParameter prmName = new OdbcParameter(); prmName.Direction = ParameterDirection.Input; prmName.OdbcType = OdbcType.VarChar; prmName.Value = txtName.Text; prmName.ParameterName = "@Name"; ErasmusInsertCommand.Parameters.Add(prmName); I've also tried it with: private void btnSave_Click(object sender, EventArgs e) { try { string InsertString = "INSERT INTO Erasmus.Publisher(Name, PublisherURL) VALUES(@Name,@URL)"; ErasmusTransaction = ErasmusConnection.BeginTransaction(IsolationLevel.ReadCommitted); ErasmusInsertCommand = new OdbcCommand(InsertString, ErasmusConnection, ErasmusTransaction); ErasmusInsertCommand.Parameters.Add("@Name", OdbcType.VarChar, 100).Value = txtName.Text; (hope that formats right.) Just before we get to the actual query, I've got a messagebox showing ErasmusInsertCommand.CommandText. "@Name" and "@URL" are not switched with the contents of the text boxes on the form (though in all honesty I'm not sure if they should be; perhaps I should be checking the parameter values?). The transaction is rolled back, because the insert command fails. The beginning of the error message (I don't get the whole thing in the message box) is: ERROR [42000][Cache ODBC][State:37000][Native Code 12] [C:\Documents and Settings\[etc.]] [SQLCODE: -12: A term expected, beginning with one of the following: identifier, constant, aggregate, $$, :, (, +, -, %ALPHALP, %EXACT, %SQLSTRING, %SQLUPPER, %STRING, or %UPPER] [Cache Error: SYNTAXerrdone+1^%qaqqt] [Details: Prepare] I've left out some greater-than and less-than symbols in order not to confuse LJ. Despite what I see in the error message, I am hoping against hope this is a generic error message, and someone's gotten it on another database (or that someone here works with Cache). All I get from the Intersystems docs about is is an error reference that gives me the same message, and not what I can do about it. If anyone has any ideas, I'm at my wits' end with this... oh, yeah: C# 2005 Express Edition, .Net 2.0. Thanks. Source: http://www.livejournal.com/community/csharp/46500.html
|