Field MEMO value NULL trouble

M

Manuel Adam

Hello everyone!

I am using a StoredProcedure with Microsoft Access.

COMMAND.Connection = CON;
COMMAND.CommandText="[new Entry]";
COMMAND.CommandType = System.Data.CommandType.StoredProcedure;
COMMAND.Parameters.Add("@Field1",OleDbType.Guid).Value = new
System.Guid(Cookie1.Value);
COMMAND.Parameters.Add("@Field2",OleDbType.Guid).Value = new
System.Guid(Cookie2.Value);
COMMAND.Parameters.Add("@Field3",OleDbType.VarChar,255).Value =
Textbox1.Text;
// Memo field that shouldn't be NULL
COMMAND.Parameters.Add("@Field4",OleDbType.VarChar,4000).Value =
Textbox2.Text;
if(this.Textbox3.Text.Length==0) // MEMO field that can be NULL.
COMMAND.Parameters.Add("@Field5",OleDbType.VarChar,4000).Value =
String.Empty;
// null won't work either.

int temp = COMMAND.ExecuteNonQuery(); // Exception ->>

System.Data.OleDb.OleDbException: Parameter[@Field5] has no default value.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

Do anyone know a solution for this?

Manuel
_no_spam * not belongs to the email address.
Only reply to Newsgroup.
 
M

Manuel Adam

Manuel Adam said:
Hello everyone!

I am using a StoredProcedure with Microsoft Access.

COMMAND.Connection = CON;
COMMAND.CommandText="[new Entry]";
COMMAND.CommandType = System.Data.CommandType.StoredProcedure;
COMMAND.Parameters.Add("@Field1",OleDbType.Guid).Value = new
System.Guid(Cookie1.Value);
COMMAND.Parameters.Add("@Field2",OleDbType.Guid).Value = new
System.Guid(Cookie2.Value);
COMMAND.Parameters.Add("@Field3",OleDbType.VarChar,255).Value =
Textbox1.Text;
// Memo field that shouldn't be NULL
COMMAND.Parameters.Add("@Field4",OleDbType.VarChar,4000).Value =
Textbox2.Text;
if(this.Textbox3.Text.Length==0) // MEMO field that can be NULL.
COMMAND.Parameters.Add("@Field5",OleDbType.VarChar,4000).Value =
String.Empty;
// null won't work either.

int temp = COMMAND.ExecuteNonQuery(); // Exception ->>

System.Data.OleDb.OleDbException: Parameter[@Field5] has no default value.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

Do anyone know a solution for this?

Oppps, I just found the topic about Nulls posted yesterday.
Got it. Works now with DBNull.Value :)

Manuel
_no_spam * not belongs to the email address.
Only reply to Newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top