簡體   English   中英

嘗試從asp.net Webforms插入時出現42703 postgres錯誤

[英]42703 postgres error while trying to insert from asp.net webforms

我已經寫了這段代碼

NpgsqlCommand command = new NpgsqlCommand("INSERT INTO public.\"Customer_Table\"(\"Customer_ID\", \"Location_Name\", \"Item_Name\", \"PhNo\") VALUES(i,'Vijayawada',x, y); ", connection);

這里的i,x,y是變量。

我有一個例外:

{“ 42703:列“ i”不存在”}

該錯誤消息表示該代碼正試圖像您想要variable i's value那樣,將文字i插入與variable i's value相對的數據庫中。

這是將變量添加到插入查詢中的一種方法:

它可能不一定能解決問題,但可以幫助您將變量的值發送到insert語句中。

NpgsqlCommand command = new NpgsqlCommand("INSERT INTO public.\"Customer_Table\"(\"Customer_ID\", \"Location_Name\", \"Item_Name\", \"PhNo\") VALUES(@i,'Vijayawada',@x, @y); ", connection);
command.Parameters.AddWithValue("@i", i);
command.Parameters.AddWithValue("@x", x);
command.Parameters.AddWithValue("@y", y);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM