求救!!数据库INSERT出错,给指点一下!!!

Kenny_Glacier 2005-11-29 01:21:52
private void Button2_Click(object sender, System.EventArgs e)
{
string strDSN ="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath("/WebApplication1/reg2.mdb");
OleDbCommand Cmd;
OleDbConnection Conn;
string strSQL="INSERT INTO reg VALUES('5','"+ TextBox2.Text + "','"+TextBox3.Text + "')";
Conn = new OleDbConnection(strDSN);
Conn.Open();
Cmd = new OleDbCommand();
Cmd.Connection=Conn;
Cmd.CommandText=strSQL;
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
}



操作必须使用一个可更新的查询。


行 91: Cmd.Connection=Conn;
行 92: Cmd.CommandText=strSQL;
行 93: Cmd.ExecuteNonQuery();
行 94: Cmd.Connection.Close();



...全文
177 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
hcaihao 2006-01-30
  • 打赏
  • 举报
回复
SQL保留关键字:
action
add
aggregate
all
alter
after
and
as
asc
avg
avg_row_length
auto_increment
between
bigint
bit
binary
blob
bool
both
by
cascade
case
char
character
change
check
checksum
column
columns
comment
constraint
create
cross
current_date
current_time
current_timestamp
data
database
databases
date
datetime
day
day_hour
day_minute
day_second
dayofmonth
dayofweek
dayofyear
dec
decimal
default
delayed
delay_key_write
delete
desc
describe
distinct
distinctrow
double
drop
end
else
escape
escaped
enclosed
enum
explain
exists
fields
file
first
float
float4
float8
flush
foreign
from
for
full
function
global
grant
grants
group
having
heap
high_priority
hour
hour_minute
hour_second
hosts
identified
ignore
in
index
infile
inner
insert
insert_id
int
integer
interval
int1
int2
int3
int4
int8
into
if
is
isam
join
key
keys
kill
last_insert_id
leading
left
length
like
lines
limit
load
local
lock
logs
long
longblob
longtext
low_priority
max
max_rows
match
mediumblob
mediumtext
mediumint
middleint
min_rows
minute
minute_second
modify
month
monthname
myisam
natural
numeric
no
not
null
on
optimize
option
optionally
or
order
outer
outfile
pack_keys
partial
password
precision
primary
procedure
process
processlist
privileges
read
real
references
reload
regexp
rename
replace
restrict
returns
revoke
rlike
row
rows
second
select
set
show
shutdown
smallint
soname
sql_big_tables
sql_big_selects
sql_low_priority_updates
sql_log_off
sql_log_update
sql_select_limit
sql_small_result
sql_big_result
sql_warnings
straight_join
starting
status
string
table
tables
temporary
terminated
text
then
time
timestamp
tinyblob
tinytext
tinyint
trailing
to
type
use
using
unique
unlock
unsigned
update
usage
values
varchar
variables
varying
varbinary
with
write
when
where
year
year_month
zerofill
Kenny_Glacier 2005-11-30
  • 打赏
  • 举报
回复
依旧没有解决
谢谢各位了
结帖了
Kenny_Glacier 2005-11-30
  • 打赏
  • 举报
回复
依旧没有解决
谢谢各位了
结帖了
Kenny_Glacier 2005-11-29
  • 打赏
  • 举报
回复
貌似不行......
那位有现成的简单例子
发我一个
Kenng.Glacier@gmail.com
编好能用的
小弟快要崩溃了......
fphuang 2005-11-29
  • 打赏
  • 举报
回复
你将asp_net完全控制权限加上也不行吗?注意,是包含数据库文件的文件夹的权限
Kenny_Glacier 2005-11-29
  • 打赏
  • 举报
回复
本来不是只读的数据库
我连接过一次,关掉
再用access打开就提示我说数据表是只读的
为什么啊??
谁给我写一个简单的数据插入的例子阿
lonelydreamsym 2005-11-29
  • 打赏
  • 举报
回复
先在sql视图里试试你的sql语句,再不就是权限问题。
Kenny_Glacier 2005-11-29
  • 打赏
  • 举报
回复
还是不行的说

老大怎么办啊???
swordragon 2005-11-29
  • 打赏
  • 举报
回复
老大
属性里没有安全这个选项阿
++++++++++++++

我的电脑 - 工具 - 文件夹选项 - 表示 - 去掉简易共享即可。
Kenny_Glacier 2005-11-29
  • 打赏
  • 举报
回复
老大
属性里没有安全这个选项阿
jxufewbt 2005-11-29
  • 打赏
  • 举报
回复
解决方法:
右击mdb文件->属性->安全->完全控制->确定
jxufewbt 2005-11-29
  • 打赏
  • 举报
回复
mdb文件权限不够
Kenny_Glacier 2005-11-29
  • 打赏
  • 举报
回复
自己先顶一下

62,242

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧