C#是菜鸟,想问一下下面那个NAMESPACE一堆错误,想问一下哪里错了错误 1 类、结构或接口成员声明中的标记“try”无效 E:\Web\App_Code\Service.cs 29 5 E:\Web\
错误 2 类、结构或接口成员声明中的标记“(”无效 E:\Web\App_Code\Service.cs 31 16 E:\Web\
错误 3 类、结构或接口成员声明中的标记“(”无效 E:\Web\App_Code\Service.cs 32 23 E:\Web\
错误 4 命名空间并不直接包含诸如字段或方法之类的成员 E:\Web\App_Code\Service.cs 34 5 E:\Web\
错误 5 应输入类型、命名空间定义或文件尾 E:\Web\App_Code\Service.cs 45 1 E:\Web\using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using system.data.sqlclient;[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} [WebMethod]
public string HelloWorld() {
return "Hello World";
}
}
namespace connect2sqlserver
{
class conectionsql
{
string connstring = "data Source=192.168.0.251;Initial Catalog=dataexchange;User ID=sa";
sqlconnection conn = new sqlconnection(connstring);
try
{
conn.open();
Console.writeline("已经连接");
}
catch (sqlexception e)
{
Console.writeline("连接错误,原因:"+e);
}
finally
{
conn.close();
console.writeline("连接已经关闭"); }
}
}
错误 2 类、结构或接口成员声明中的标记“(”无效 E:\Web\App_Code\Service.cs 31 16 E:\Web\
错误 3 类、结构或接口成员声明中的标记“(”无效 E:\Web\App_Code\Service.cs 32 23 E:\Web\
错误 4 命名空间并不直接包含诸如字段或方法之类的成员 E:\Web\App_Code\Service.cs 34 5 E:\Web\
错误 5 应输入类型、命名空间定义或文件尾 E:\Web\App_Code\Service.cs 45 1 E:\Web\using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using system.data.sqlclient;[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} [WebMethod]
public string HelloWorld() {
return "Hello World";
}
}
namespace connect2sqlserver
{
class conectionsql
{
string connstring = "data Source=192.168.0.251;Initial Catalog=dataexchange;User ID=sa";
sqlconnection conn = new sqlconnection(connstring);
try
{
conn.open();
Console.writeline("已经连接");
}
catch (sqlexception e)
{
Console.writeline("连接错误,原因:"+e);
}
finally
{
conn.close();
console.writeline("连接已经关闭"); }
}
}
解决方案 »
- 谁能解析下面这段json
- 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访
- 同样Section 同样Key 同样的值 为什么ini写入分两行
- ASPxGridView中最后一行的各列都要合计,如何实现?
- 高手指点,关于反射
- 用Response.Redirect "file.asp"页面转换出错,如何解决?
- 在EXCEL模版中插入新行 急!!! 高手们帮帮忙!!! 谢谢!!!
- 关于vcppde算法..希望不吝赐教
- 关于VC到C#的数据类型转换问题!
- 我再也不去ASP.NET版发帖子了!!!!!!!!!!
- 求高手在线等
- c#做的管理系统出现的问题,帮忙解决下吧,我快纠结死了
sqlconnection conn = new sqlconnection(connstring);
try
{
conn.open();
response.write("已经连接");
}
catch (sqlexception e)
{
response.write("连接错误,原因:"+e);
}
finally
{
conn.close();
response.write("连接已经关闭"); }
错误 1 类、结构或接口成员声明中的标记“try”无效 e:\Web\myuploaddate.dal\Class1.cs 12 5 myuploaddate.dal
错误 2 类、结构或接口成员声明中的标记“(”无效 e:\Web\myuploaddate.dal\Class1.cs 14 16 myuploaddate.dal
错误 3 类、结构或接口成员声明中的标记“(”无效 e:\Web\myuploaddate.dal\Class1.cs 15 20 myuploaddate.dal
错误 4 命名空间并不直接包含诸如字段或方法之类的成员 e:\Web\myuploaddate.dal\Class1.cs 17 5 myuploaddate.dal
错误 5 类、结构或接口成员声明中的标记“{”无效 e:\Web\myuploaddate.bll\dbhelper.cs 14 5 myuploaddate.bll
错误 6 类、结构或接口成员声明中的标记“try”无效 e:\Web\myuploaddate.bll\dbhelper.cs 18 5 myuploaddate.bll
错误 7 类、结构或接口成员声明中的标记“(”无效 e:\Web\myuploaddate.bll\dbhelper.cs 20 16 myuploaddate.bll
错误 8 类、结构或接口成员声明中的标记“(”无效 e:\Web\myuploaddate.bll\dbhelper.cs 21 20 myuploaddate.bll
错误 9 命名空间并不直接包含诸如字段或方法之类的成员 e:\Web\myuploaddate.bll\dbhelper.cs 23 5 myuploaddate.bll
错误 10 应输入类型、命名空间定义或文件尾 e:\Web\myuploaddate.bll\dbhelper.cs 33 2 myuploaddate.bll