我的函数(postgresql):
CREATE FUNCTION connec2(_X integer,_Y integer,_Z integer)
RETURNS void AS
$BODY$
BEGIN
INSERT INTO public.polepoints (X,Y,X)
VALUES(_X , _Y , _Z);
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
我的c代码:
static void Main(string[] args)
{
int X = 500;
int Y = 600;
int Z = 700;
string strReturn = "";
string ConStr = "";
string Code = "";
DataSet ds = new DataSet();
NpgsqlParameter[] parameters =
{
new NpgsqlParameter( "_X", NpgsqlDbType.Integer) { Value = X } ,
new NpgsqlParameter( "_Y", NpgsqlDbType.Integer, 20) { Value = Y } ,
new NpgsqlParameter( "_Z", NpgsqlDbType.Integer, 20) { Value = Z } ,
};
ConStr = "Server = localhost; Port = 5433; User Id = postgres; Password = DoNotShareYourPassword; Database = Geometronics";
using (NpgsqlConnection con = new NpgsqlConnection(ConStr))
{
using (NpgsqlCommand cmd = new NpgsqlCommand("connec2", con))
{
cmd.CommandType = CommandType.StoredProcedure;
NpgsqlDataAdapter da = new NpgsqlDataAdapter();
cmd.Parameters.AddRange(parameters);
da.SelectCommand = cmd;
da.Fill(ds);
}
}
string errmsg = "";
if (errmsg != "")
{
Code = "0"; strReturn = errmsg;
}
else
{
if (ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
Code = "1";
foreach (DataRow dr in ds.Tables[0].Rows)
{
strReturn += dr[0].ToString();
}
if (strReturn == "1")
{
Console.Write("Updated");
}
}
//TripDT = TripDT.ToShortDateString();
}
}
}
现在的问题是,抛出一个错误,显示函数不存在。我在连接字符串“constr=”server=localhost;端口=5433;用户id=postgres;密码=不共享;数据库=地球磁学“;”或者我的功能有什么错误。先谢谢你
暂无答案!
目前还没有任何答案,快来回答吧!