WabiSabi's Profile User Rating: -----

Reputation: 51 Whiz
Active Members
Active Posts:
201 (0.14 per day)
31-December 10
Profile Views:
Last Active:
User is offline Private

Previous Fields

Who Cares
OS Preference:
Who Cares
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:

Latest Visitors

Icon   WabiSabi I would rather ask a dumb question and look stupid once than to remain ignorant forever.

Posts I've Made

  1. In Topic: connecting to ms sql server 2008 using oledb

    Posted 29 Nov 2012

    C# is a little different so the syntax is different. When the error is something like "did you mean to invoke the method?" then you should call a method. For example cmd.ExecuteReader; should be cmd.ExecuteReader(); This now shows no errors for me but I didn't test it.
            public bool validateuser(string password, string username)
                OleDbCommand cmd = new OleDbCommand();
               // DbConnection db;
                //cmd.Connection = db.connection;
                cmd.CommandText = "select * from userlogin where password = ? and username = ?";
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("", password);
                cmd.Parameters.AddWithValue("", username);
                bool found = false;
                OleDbDataReader dr = default(OleDbDataReader);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                    found = true;
                return found;

    The following works. I have tested it. I think you need to put whatever provider you actually use, though. Maybe you can get yours working by looking at this example. Good luck!

                con = new System.Data.OleDb.OleDbConnection();
                con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/ACTUAL_FILEPATH_GOES_HERE.accdb;Jet OLEDB:Database Password=MyDbPassword;";
                string comment = "Insert!";
                int id = 1; //this is related in the other table...  must be an ID from the other table; primary key, maybe? Or just a key...
                OleDbCommand Cmd = new OleDbCommand("Insert Into Comments([Comment], ContactID) Values (@CommentParam, @ContactIDParam)", con);
                Cmd.Parameters.AddWithValue("@CommentParam", comment);
                Cmd.Parameters.AddWithValue("@ContactIDParam", id);
                //OR you can do it this way:
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = con;
                cmd.CommandText = "INSERT INTO Comments([Comment],[ContactID])  VALUES (@Comment, @ID)";
                cmd.Parameters.Add("@Comment", OleDbType.VarChar).Value = "HELPME";
                cmd.Parameters.Add("@ID", OleDbType.Integer).Value = 2;
  2. In Topic: System.Data.SqlClient.SqlException was unhandled

    Posted 8 Nov 2012

    Thank you for the replies. I tried to do as you suggested, but was unable to get the management studio installed. Apparently you have to uninstall previous versions of SQL Server and then install the express version in order to get the option for the management studio to be available.

    But I don't want to uninstall the version I have, since it is the 'regular' version, not express, and was installed by our system admin, not me. So I don't have an installation CD or anything for it. My other programs depend on it, so I can't risk losing it.

    At any rate, I tried running my program without using the emulator... and it works with NO errors. So I guess it's just the emulator that doesn't work.

    I tried installing the program on a scan gun to see if it would work that way, but it's missing a file or assembly name...

    Error message:
    "File or assembly name 'System.Data.SqlClient, Version 3.0.3600.0, Culture = neutral', PublicKey Token = 3BE235DF1C8D2AD3', or one of its dependencies, was not found."

    //one step forward... two steps back

    again thanks for the advice!
  3. In Topic: System.Data.SqlClient.SqlException was unhandled

    Posted 6 Nov 2012

    Thanks for moving it.

    I added code to catch the exception and this is what it tells me now.

    this.Adapter.SelectCommand.CommandTimeout = 600; //I added this to eliminate possible timeout. Did not fix error.
                catch(System.Data.SqlClient.SqlException e){

    The error is: Login failed for user ''. The user is not associated with a trusted SQL Server connection.

    I found a fix, but I donít have the SQL Server Management Studio.

    Is there any other way I can fix this?

My Information

Member Title:
D.I.C Head
Age Unknown
Birthday Unknown
Years Programming:

Contact Information

Click here to e-mail me



WabiSabi has no profile comments yet. Why not say hello?