Dataset DB problem

  • Hi,

    I have taken over an app from a former employee. I have a grid I want to update back to the DB. I have tried several things (Below) to connect to the DB. The grid is loaded by the DB so I kow that part is correct. I do not know what I am doing wrong. I can connect through C# Tools connect to DB that is fine. Here is what I have tried

    string conStr = @"Server = .\sqlexpress;

    Integrated Security = true;

    DataBase=PROTOTYP_DB";

    qlConnection conn = new SqlConnection(conStr);

    daPROTOTYPDB = new SqlDataAdapter("select * from Property", conn);

    SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daPROTOTYPDB);

    daPROTOTYPDB.Fill(dsProperty, "Property");

    The name of the db is PROTOTYP_DB.mdf and the path to it is D:\pm_demo\PM.Runtime.Demo\PROTOTYP_DB.mdf

    Any help would be greatly appreciated

  • the connection string you are using is not correct. There is nothing like 'Database name' in connection string. Use 'Initial catalog' instead of this, or for more information about connection strings visit this.

    http://www.connectionstrings.com

  • aftabsatti (11/14/2008)


    the connection string you are using is not correct. There is nothing like 'Database name' in connection string. Use 'Initial catalog' instead of this, or for more information about connection strings visit this.

    http://www.connectionstrings.com[/quote%5D

    Actually Database is an alternate property for connection strings, although Initial Catalog is preferred.

    I think the issue is that you are never setting the UpdateCommand property of the DataAdapter.

  • Q. have you solved this problem? let me know. thanks :hehe:

    "We never plan to Fail, We just fail to plan":)

  • string conStr = @"Server = .\sqlexpress" _

    & ";Integrated Security = true;" _

    & ";DataBase=PROTOTYP_DB";

    string strSQL = "Select * form Property"

    qlConnection conn = new SqlConnection(conStr);

    daPROTOTYPDB = new SqlDataAdapter(strsql, conn);

    SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daPROTOTYPDB);

    daPROTOTYPDB.Fill(dsProperty, "Property");

    Hope this helps.

    "We never plan to Fail, We just fail to plan":)

  • First of all I need to appologize for the wrong info I provide you with. that happens when switching from VB to CS.

    Solution: Server=".\\DBName;" +

    The "\\" well think of C++ and the + Equates to "_ & "

    😛

    thanks

    and sorry!!

    "We never plan to Fail, We just fail to plan":)

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply