Click here to Skip to main content
16,006,341 members
Home / Discussions / Database
   

Database

 
GeneralDuplicated Value Pin
Mazdak23-Mar-02 20:15
Mazdak23-Mar-02 20:15 
GeneralRe: Duplicated Value Pin
Roger Wright23-Mar-02 20:21
professionalRoger Wright23-Mar-02 20:21 
GeneralRe: Duplicated Value Pin
Mazdak23-Mar-02 20:38
Mazdak23-Mar-02 20:38 
GeneralRe: Duplicated Value Pin
Roger Wright24-Mar-02 5:10
professionalRoger Wright24-Mar-02 5:10 
GeneralRe: Duplicated Value Pin
Mazdak24-Mar-02 6:29
Mazdak24-Mar-02 6:29 
GeneralRe: Duplicated Value Pin
James T. Johnson25-Mar-02 16:40
James T. Johnson25-Mar-02 16:40 
GeneralRe: Duplicated Value Pin
Mazdak25-Mar-02 19:35
Mazdak25-Mar-02 19:35 
GeneralProblem using a Parameterized Command as the Select Command for a Data Adapter Pin
Paulo23-Mar-02 7:17
Paulo23-Mar-02 7:17 
Seems that using a parameterized query as a SelectCommand for an OleDbDDataAdapter to fill a DataSet doesn't work!
The following code is how I'm doing that. All the code is inside an try/catch block. The language i'm using is C#


// Using a UDL file for the connection string
string strDBConn = "FileName=D:\Contacts.udl;";

// Sets up the connection
OleDbConnection conn = new OleDbConnection(strDBConn);
conn.Open(strDBConn);

// Creates a new command
OleDbCommand cmd = new OleDbCommand(
"select * from dbo.Contacts where contact_id = ?", conn);

// Sets up the Data Adapter
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;

// Sets the Command parameters
param = da.SelectCommand.Parameters.Add (
"@contact_id", OleDbType.Numeric, 9, "entid_id");
param.Value = 1; // The parameter value

// creates a new DataSet
DataSet dsResult = new DataSet()

// Fills the DataSet
da.Fill(dsResult);


Somehow in the last instruction it generates an exception that even 'catch (Exception e)' can't get exactly because in spite of falling in this catch block the 'e' (the exception) is null!
But the reason he is throwing some weird exception is because the parameters are not being declared first before querying the database with the parameterized select command and consequently the string that is being sent is only "select * from dbo.Contacts where contact_id = @P1" and nothing else.
I'm using a .UDL file to set my connection string which is set with valid parameters because it's being used everywhere else in the app and it works perfectly.
My Database is SQL Server 2000... Yeah, of course I could use SqlDataAdapter and all the other classes specific for SQL Server but the fact is that I want to use an .UDL file to set my datasource and the only way to do this is using the OleDb... classes. UDL files doesn't work with SqlConnection in case you didn't know.

So... am I doing something wrong here in setting the Data Adapter to a parameterized query? Is this a bug in the .NET framework? Can you help me out with this? Thanks in advance Smile | :)


Best Regards,
Paulo

GeneralASP DLL PROBLEM....HELP!!!! Pin
22-Mar-02 11:18
suss22-Mar-02 11:18 
GeneralRe: ASP DLL PROBLEM....HELP!!!! Pin
Loki27-Mar-02 22:47
Loki27-Mar-02 22:47 
GeneralAnother problem in ADO.NET Pin
Mazdak22-Mar-02 9:30
Mazdak22-Mar-02 9:30 
GeneralADO.NET Pin
Mazdak22-Mar-02 7:44
Mazdak22-Mar-02 7:44 
GeneralRe: ADO.NET Pin
Andres Manggini22-Mar-02 8:20
Andres Manggini22-Mar-02 8:20 
GeneralRe: ADO.NET Pin
Mazdak22-Mar-02 9:34
Mazdak22-Mar-02 9:34 
GeneralRe: ADO.NET Pin
Andres Manggini22-Mar-02 10:06
Andres Manggini22-Mar-02 10:06 
GeneralRe: ADO.NET Pin
Mazdak22-Mar-02 18:26
Mazdak22-Mar-02 18:26 
GeneralRe: ADO.NET Pin
AndyG22-Mar-02 18:44
AndyG22-Mar-02 18:44 
GeneralRe: ADO.NET Pin
Mazdak22-Mar-02 19:11
Mazdak22-Mar-02 19:11 
GeneralRe: ADO.NET Pin
AndyG22-Mar-02 19:33
AndyG22-Mar-02 19:33 
GeneralRe: ADO.NET Pin
Mazdak22-Mar-02 20:18
Mazdak22-Mar-02 20:18 
QuestionHow do you deploy SQL Server solutions. Pin
Michael P Butler22-Mar-02 1:41
Michael P Butler22-Mar-02 1:41 
AnswerRe: How do you deploy SQL Server solutions. Pin
Carlos Antollini22-Mar-02 2:22
Carlos Antollini22-Mar-02 2:22 
GeneralRe: How do you deploy SQL Server solutions. Pin
Michael P Butler22-Mar-02 2:34
Michael P Butler22-Mar-02 2:34 
GeneralRe: How do you deploy SQL Server solutions. Pin
Carlos Antollini22-Mar-02 2:39
Carlos Antollini22-Mar-02 2:39 
GeneralRe: How do you deploy SQL Server solutions. Pin
Michael P Butler22-Mar-02 2:50
Michael P Butler22-Mar-02 2:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.