开发者

c# sql database express [closed]

开发者 https://www.devze.com 2023-01-26 17:34 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago. 开发者_运维知识库

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)"; 
0

精彩评论

暂无评论...
验证码 换一张
取 消