错误1'System.Data.SqlClient ...

编程入门 行业动态 更新时间:2024-10-25 06:32:19
本文介绍了错误1'System.Data.SqlClient ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我收到以下错误错误1'System.Data.SqlClient.SqlConnection'是'类型',但在下面的代码中使用像'变量',请帮助

string imgLoc = ; public Retrieve() { InitializeComponent(); } private void 浏览( object sender,RoutedEventArgs e) { SqlConnection cn = SqlConnection( global :: DatabaseApp.Properties。 Settings.Default.Database1ConnectionString); 尝试 { OpenFileDialog dlg = new 打开文件对话框(); dlg.Filter = JPG文件(* .jpg)| * .jpg | GIF文件(*。 gif)| * .gif |所有文件(*。*)| *。*; dlg.Title = 选择学生照片; 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(); }

解决方案

你在<缺少 new 这个词pre> SqlConnection cn = SqlConnection(global :: DatabaseApp.Properties.Settings.Default.Database1ConnectionString);

ie

SqlConnection cn = new SqlConnection(global :: DatabaseApp.Properties.Settings.Default.Database1ConnectionString);

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

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(); }

解决方案

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);

更多推荐

错误1'System.Data.SqlClient ...

本文发布于:2023-11-14 15:27:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587836.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   System   Data   SqlClient

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!