none
DbCommand and unnamed parameters RRS feed

  • Question

  • I'm using DbProviderFactory to create a connection. With this connection I create a DbCommand. I add DbParameters and execute the query.
    This way it doesn't matter if the datasource is Sql Server, Access, Oracle etc.
    But there's a problem. When I create a connection for an Odbc database I need to use unnamed parameters, but when I create a connection for Sql Server I need to use named parameters. I thought using DbParameter would solve the problem for me, but it doesn't.
    So not knowing which datasource I'm dealing with I can't create the commandtext, because I don't know if I need named parameters or not. So I don't know if the commandtext needs to look like this (odbc):
    UPDATE Humres SET fullname = ?
    Or like this (sql server):
    UPDATE Humres SET fullname = @fullname
    Or like this (oracle):
    UPDATE Humres SET fullname = :fullname

    So how can I fix this?
    Thursday, August 2, 2007 1:03 PM

Answers

All replies