我无法找到错误 [英] am not able to find what is the error
问题描述
请通过以下方式向我建议我需要做什么。请帮助我做一个更新鲜的。
这是我的班级,其中包含一些属性
< pre lang =cs> 使用系统;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Text;
命名空间 proinsert
{
public class insert
{
private int 模式;
public int 模式
{
get { return 模式; }
set {mode = value ; }
}
private int stid;
public int Stid
{
get { return stid; }
set {stid = value ; }
}
private string stname;
public string Stname
{
get { return stname; }
set {stname = value ; }
}
private string staddress;
public string Staddress
{
get { return staddress; }
set {staddress = value ; }
}
}
}
这是我的dal
使用系统;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Text;
使用 System.Data;
使用 proinsert;
使用 System.Data.SqlClient;
命名空间 studentdal
{
public class stude
{
public SqlConnection con;
public stude()
{
con = new SqlConnection( 数据源=。\\sqlexpress;初始目录= g;集成安全性=真) ;
con.Open();
}
public DataView fetch( int stids)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = h;
cmd.Parameters.Add( new SqlParameter( @sid,SqlDbType.Int))。Value = stids;
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
return dt.DefaultView;
}
public int isy(proinsert.insert ayo, out string stadre)
{
SqlCommand cm = new SqlCommand();
cm.Connection = con;
cm.CommandText = oi;
cm.Parameters.Add( new SqlParameter( @mode,SqlDbType.Int))。Value = ayo.Mode;
cm.Parameters.Add( new SqlParameter( @sid,SqlDbType.Int))。Value = ayo.Stid;
cm.Parameters.Add( new SqlParameter( @sname,SqlDbType.VarChar))。Value = ayo.Stname;
cm.Parameters.Add( new SqlParameter( @sad,SqlDbType.VarChar))。Direction = ParameterDirection.Output;
cm.ExecuteNonQuery();
stadre = Convert.ToString(cm.Parameters [ @ sad]。Value) ;
return Convert.ToInt32(cm.Parameters [ @sad跨度>]值);
}
}
}
我试图传递价值asp.net page.kindly请如何从前端传递值。我的数据库是
create 数据库 g
使用 g
create table student(stid int primary key ,stname varchar ( 50 ),staddress varchar ( 50 ))
alter procedure h
( @ sid int )
as
开始
如果 @ sid = null
开始
选择 * 来自学生
结束
其他
开始
选择 * 来自学生其中 stid = @ sid
end
end
创建 过程 oi
( @ mode int , @ sid int , @sname varchar ( 80 ), @伤心 varchar ( 30 )out)
as
开始 交易
if @ mode = 1
begin
insert 进入学生值( @ sid , @ sname , @ sad )
end
else
开始
if @ mode = 2
begin
update student < span class =code-keyword> set stname = @ sname where stid = @ sid
结束
end
错误4否方法'isy'的重载需要4个参数
查看错误消息。
然后看看你的班级:
命名空间 studentdal
{
public class stude
{
public SqlConnection con;
public stude()
{
...
}
public DataView fetch( int stids)
{
...
}
< span class =code-keyword> public int isy(proinsert.insert ayo, out string stadre)
{
...
}
}
}你有一个名为
isy
的方法 - 它需要两个参数,其中一个是out
参数。
现在看看你是怎么称呼的:
stude oki = new stude( );
oki.isy(a,b,name.Text,address.Text);四个参数,没有一个
out
参数。
你需要打电话只需要两个参数的方法,或者写一个新的方法来获取你想要的四个...
please suggest me what i need to do by seeing the below.please kindly help me out am a fresher.
this is my class which contains some properties
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace proinsert
{
public class insert
{
private int mode;
public int Mode
{
get { return mode; }
set { mode = value; }
}
private int stid;
public int Stid
{
get { return stid; }
set { stid = value; }
}
private string stname;
public string Stname
{
get { return stname; }
set { stname = value; }
}
private string staddress;
public string Staddress
{
get { return staddress; }
set { staddress = value; }
}
}
}
this is my dal
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using proinsert;
using System.Data.SqlClient;
namespace studentdal
{
public class stude
{
public SqlConnection con;
public stude()
{
con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=g;Integrated Security=True");
con.Open();
}
public DataView fetch(int stids)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "h";
cmd.Parameters.Add(new SqlParameter("@sid", SqlDbType.Int)).Value = stids;
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
return dt.DefaultView;
}
public int isy(proinsert.insert ayo, out string stadre)
{
SqlCommand cm = new SqlCommand();
cm.Connection = con;
cm.CommandText = "oi";
cm.Parameters.Add(new SqlParameter("@mode", SqlDbType.Int)).Value = ayo.Mode;
cm.Parameters.Add(new SqlParameter("@sid", SqlDbType.Int)).Value = ayo.Stid;
cm.Parameters.Add(new SqlParameter("@sname", SqlDbType.VarChar)).Value = ayo.Stname;
cm.Parameters.Add(new SqlParameter("@sad", SqlDbType.VarChar)).Direction=ParameterDirection.Output;
cm.ExecuteNonQuery();
stadre = Convert.ToString(cm.Parameters["@sad"].Value);
return Convert.ToInt32(cm.Parameters["@sad"].Value);
}
}
}
and am trying to pass value from the asp.net page.kindly please how can pass the value from front end.and my database is
create database g
use g
create table student(stid int primary key,stname varchar(50),staddress varchar(50))
alter procedure h
(@sid int)
as
begin
if @sid=null
begin
select * from student
end
else
begin
select * from student where stid=@sid
end
end
create procedure oi
(@mode int, @sid int,@sname varchar(80),@sad varchar(30) out)
as
begin transaction
if @mode=1
begin
insert into student values(@sid,@sname,@sad)
end
else
begin
if @mode=2
begin
update student set stname=@sname where stid=@sid
end
end
Error 4 No overload for method 'isy' takes 4 arguments
Look at the error message.
Then look at your class:
namespace studentdal { public class stude { public SqlConnection con; public stude() { ... } public DataView fetch(int stids) { ... } public int isy(proinsert.insert ayo, out string stadre) { ... } } }You have one method called
isy
- it takes two parameters, one of them anout
parameter.
Now look at how you are calling it:
stude oki = new stude(); oki.isy(a,b,name.Text,address.Text);
Four parameters, none of them
out
parameters.
You need to either call the method with just the required two parameters, or write a new method which takes the four you want to give it...
这篇关于我无法找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!