注册 登录
编程论坛 C# 论坛

求大神帮忙看一下错误

yj1468879574 发布于 2014-12-25 08:50, 646 次点击
//帮我看看哪里出错了,谢谢,根本无法运行!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using system.Data.SqlClient;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //连接字符串
            private const string strConn=@"Data Source=.;Initial catalog=yangjie;"+"User ID=sa'pwd=Yj666888";
        //创建数据库连接
        Public bool checkuserInfo(string USerName,string pwd,ref string strMsg){
        SqlConnection conn=new SqlConnection(strConn);
        try{
            //创建Sql语句
        string strSql="select count(*) from yangjie;";
        conn.Open();
        //创建command 命令
        SqlCommand comm=new SqlCommand(strconn,conn);
        int iret=(int)comm.ExecuteScalar();//强制类型转换 转换成int
        }
        }
        }
    }
}
7 回复
#2
xydddaxia2014-12-25 09:00
sa后面的单引号改成分号
#3
tlliqi2014-12-25 17:58
出错提示?
#4
over12302014-12-25 20:46
几处大小写错误,
try后面没有catch或者finally.
Main()里面好像不能有方法(此处我还不确定)
checkuserInfo是bool型,需要有返回值。

#5
Maick2014-12-30 16:04
//连接字符串
            private const string strConn=@"Data Source=.;Initial catalog=yangjie;"+"User ID=sa'pwd=Yj666888";

            string strSql="select count(*) from yangjie;";

请搞清楚
Initial catalog=是数据库的名字..而不是表名
#6
yj14688795742015-01-06 08:20
回复 5楼 Maick
我的是表名,谢谢你啊
#7
yj14688795742015-01-06 08:21
回复 2楼 xydddaxia
谢谢,
#8
yj14688795742015-01-06 08:21
回复 3楼 tlliqi
嗯嗯,知道了,谢谢
1