c# sql database express [closed]
Im trying to insert data into a database table, the problem is that my column name (Recent Activity) has a space and its causing a problem.
sql_Query = "INSERT INTO [SprinklerHistory] (";
sql_Query += "[Recent Activity], Date, Time)";
sql_Query += "VALUES (";
sql_Query += "@Recent Activity, @Date, @Time)";
When passing parameter you don't need to have them directly matchup to the field names. A larger code snippet would assist but the following should work. Also try and avoid naming fields with potentially reserved words such as Date and Time.
sql_Query = "INSERT INTO [SprinklerHistory] (";
sql_Query += "[Recent Activity], [Date], [Time])";
sql_Query += "VALUES (";
sql_Query += "@RecentActivity, @Date, @Time)";
精彩评论