[英]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.