Click here to Skip to main content
15,886,031 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am getting the following error "Error 1 'System.Data.SqlClient.SqlConnection' is a 'type' but is used like a 'variable'" in the below code kindly help

C#
string imgLoc = "";
        
        public Retrieve()
        {
            InitializeComponent();
        }

        private void Browse(object sender, RoutedEventArgs e)
        {
            SqlConnection cn = SqlConnection(global::DatabaseApp.Properties.Settings.Default.Database1ConnectionString);

            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|All Files(*.*)|*.*";
                dlg.Title = "Select Student Picture";
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    imgLoc = dlg.FileName.ToString();
                    picStud.ImageLocation = imgLoc;
                }
            }
            catch(Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
        }

        private SqlConnection SqlConnection(string p)
        {
            throw new NotImplementedException();
        }
Posted
Updated 31-Mar-15 3:24am
v2

1 solution

You are missing the word new in
SqlConnection cn = SqlConnection(global::DatabaseApp.Properties.Settings.Default.Database1ConnectionString);
i.e.
SqlConnection cn = new SqlConnection(global::DatabaseApp.Properties.Settings.Default.Database1ConnectionString);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900