错误1'System.Data.SqlClient ... [英] Error 1 'System.Data.SqlClient...
本文介绍了错误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 wordnew
inSqlConnection cn = SqlConnection(global::DatabaseApp.Properties.Settings.Default.Database1ConnectionString);i.e.
SqlConnection cn = new SqlConnection(global::DatabaseApp.Properties.Settings.Default.Database1ConnectionString);
这篇关于错误1'System.Data.SqlClient ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文