How to add a default value?

S

Shapper

Hello,

I work with Web Matrix and I created a DataSet which SQL Query uses the
parameter Code in the URL:

....
Dim dbParam_message_code As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_message_code.ParameterName = "@message_code"
dbParam_message_code.Value = Request.QueryString("code")
dbParam_message_code.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_message_code)
....

What I want is set a default value when code is empty or when it's not
present in the URL. I am getting an error with this in those cases.

Thank You,
Miguel
 
K

Karl Seguin

Check for the default value

dim code as string = Request.QueryString("code")
if code is nothing then
code = "someDefaultCode"
end if

....
dbParam_message_code.Value = code


Karl
 
S

Shapper

I knew doing it that way.
I wanted to know if there was any optional parameter in
Request.QueryString or in other commands I use to set a default value in
case is empty.

Cheers,
Miguel

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message REMOVE @ REMOVE openmymind REMOVEMETOO .
ANDME net:
 
S

Shapper

Thanks Karl.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message REMOVE @ REMOVE openmymind REMOVEMETOO .
ANDME net:
 

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