Server2008 n Howdy Worldn New D.I.C Head Posts:
29 Joined:
03-February 09
I am obtaining problems connecting to your AdventureWorks_Data.mdf. I can connect to a report server temp db but there is no information in it.
Working with similar code to connect to AdventureWorks_Data.mdf gives an error "network related or instance specific error occurred
while connecting to SQL Server". I don't get it as the temp db connect works (see // above actual ran code). Help Please!
public void LoadSql() { // string connectionString = @"Provider=System.Data.SqlClient; // Persist Security Info=False; // Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS2\MSSQL\DATA\ReportServer $SQLEXPRESS2TempDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True; // Integrated Security=SSPI; // Trusted_Connection=TRUE; // Application Name=SampleCSharpApplication"; // string connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS2\MSSQL\DATA\ReportServer $SQLEXPRESS2TempDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; string connectionString = @"Data Source=Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS2\MSSQL\DATA\AdventureWor ks_Data.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; string sqlSel = @"Select * From Address"; SqlConnection conndb = new SqlConnection(connectionString); //make a OleDbConnection object DataSet ds = new DataSet(); //make a DataSet object try SqlDataAdapter myAdapter = new SqlDataAdapter(sqlSel,
windows 7 professional 64 bit, conndb); //Using the OleDbDataAdapter execute the query myAdapter.Fill(ds,
microsoft office 2007 Professional Plus activation key, "Address"); //Fill the DataSet with the Table 'Customers' gridColors.DataSource = ds.Tables["Address"]; myAdapter.Dispose(); catch (Exception e) MessageBox.Show("Error in connecting! " + e.ToString(),
microsoft office pro plus 2010 32bit, "Error"); finally conndb.Close(); //Close the OleDbConnection conndb.Dispose(); }
This post has been edited by getajob1: 20 February 2009 - 03:37 PM