Friday 15 August 2014

c# - Retrieving image from sql table using a file path, code error -


A good word called Darin gave me some code to get an image through my code path.

However, when I try to execute the code, I get a "tap reference exception"; the user is dismissed by the code; Use the 'new' keyword to create an object instance on the first virtual line.

The code can be found below:

  var connectionString = Configuration Manager. Connection strings ["SomeCN"]. ConnectionString; (Var cnd = cn.CreateCommand ()) (cn.Open ()) (var cn = new SqlConnection ("Data Source = STRSQL04; Initial Catalog = PDC; Integrated Security = True" Cmd.CommandText = "Template Select imageID from where the member ID = FM00012 "; cmd.Parameters.AddWithValue (" FM00012 ", 5); {if reader.Read ()) {var reader = Root ()) {var filepath = Reader.GetString (0); Image1.ImageUrl = filepath;}}} Can anyone explain the error on my behalf?   

itemprop = "text">

In your app config, you have a connection type called "SomeCN" (Or whatever you are using for real), so when you try to access the ConnectionString.ConnectionString parameter, this is a nullifier.

Can you post content of your app.config , or at least connection to element, we can see?

  • (When you try it, you will see one type of settings in the Settings Editor dropdown "ConnectionString").

No comments:

Post a Comment