November 14, 2008 at 10:51 am
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
November 14, 2008 at 1:18 pm
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.
November 17, 2008 at 2:05 pm
aftabsatti (11/14/2008)
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.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
November 21, 2008 at 9:34 am
Q. have you solved this problem? let me know. thanks :hehe:
"We never plan to Fail, We just fail to plan":)
November 21, 2008 at 9:40 am
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":)
November 24, 2008 at 7:50 am
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