troubleshooting Question

Badly need help in Redim'ing C# code

Avatar of mousemat24
mousemat24 asked on
C#
16 Comments1 Solution632 ViewsLast Modified:
Hi there

Wonder if you can help me, I have the following code:

SqlCommand[] sqlQuery = new SqlCommand[10];
Byte[] data = new Byte[10];
MemoryStream[] stream = new MemoryStream[10];
LinkedResource[] logo = new LinkedResource[10];

if (m.Count > 0)
            {
                int i = 0;  
                foreach (Match m1 in m)
                {

sqlQuery[i] = new SqlCommand("SELECT Data FROM Attachments WHERE (fileName='" + getImageF + "')", myConnection1);

data = (byte[])sqlQuery[i].ExecuteScalar();
stream[i] = new MemoryStream(data);
logo[i] = new LinkedResource(stream[i], "image/jpeg");

logo[i].ContentType.MediaType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
logo[i].ContentId = "image"+i.ToString();
emailBody1 = HTMLContent.Replace(m1.Value, "<img src='cid:image" + i.ToString() + "'>");
htmlView.LinkedResources.Add(logo[i]);
i++;                    
                    myConnection1.Close();
                }
            }
Can someone please help me in makeing this more efficient i.e. get rid of the hardcoded value of 10 (redim it)

The reason, why i placed 10 is that, I dont know how to redim the code, I've seen many example, but dont know how to incorporate it with the code above

Many thanks
Mousemat24
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 16 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros