ExecuteNonQuery - 问题 [英] ExecuteNonQuery - problem
问题描述
我正在尝试在VB 2005中进行简单操作(插入数据库)和
SQL Server。
代码如下:
Dim sConnectionString As String = _
" Data
Source = .\SQLEXPRESS; AttachDbFilename = | DataDirector y | \DB.mdf ....
Dim cnDB As New SqlConnection(sConnectionString)
cnDB.Open()
Dim strSQL As String
strSQL =" INSERT INTO Company(CompanyName)VALUES(''four'')"
Dim命令As SqlCommand = New SqlCommand(strSQL,cnDB)
command.ExecuteNonQuery()
cnDB.Close()
>
但是该行没有插入到数据库中,也没有任何错误。
最初我想使用存储过程但是为了使它成为
工作我做了最简单的操作 - 没有成功...
你知道出了什么问题吗?
问候
BR
Hi,
I''m trying to make a simple operation (insert into DB) in VB 2005 and
SQL Server.
The code is as follows:
Dim sConnectionString As String = _
"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\DB.mdf....
Dim cnDB As New SqlConnection(sConnectionString)
cnDB.Open()
Dim strSQL As String
strSQL = "INSERT INTO Company (CompanyName) VALUES (''four'')"
Dim command As SqlCommand = New SqlCommand(strSQL, cnDB)
command.ExecuteNonQuery()
cnDB.Close()
But the row is not inserted into DB and also there is no any error.
Initialy I wanted to use stored procedure but in order to make it
working I made the simplest operation - without success...
Do you have any idea what is wrong?
Regards
BR
推荐答案
Dubug使用这个结构,看看ex.message的价值告诉你什么
试试
''//你的代码
赶上exception''//断点这里
结束尝试
" b_r" < b_r @ wp''_ cut_it''。plwrote in message
news:2d ************************* **@news.chello.pl。 ..
Dubug using this construct and see what the value of ex.message tells you
Try
''//Your Code
Catch ex as Exception ''//breakpoint here
End try
"b_r" <b_r@wp''_cut_it''.plwrote in message
news:2d***************************@news.chello.pl. ..
我想在VB 2005中做一个简单的操作(插入数据库)和SQL
服务器。
代码如下:
Dim sConnectionString As String = _
"数据
来源= .\SQLEXPRESS; AttachDbFilename = | DataDirector y | \DB.mdf ....
Dim cnDB As New SqlConnection(sConnectionString)
cnDB.Open()
Dim strSQL As String
strSQL =" INSERT INTO Company( CompanyName)VALUES(''four'')"
Dim命令As SqlCommand = New SqlCommand(strSQL,cnDB)
command.ExecuteNonQuery()
cnDB.Close()
但该行未插入数据库,也没有任何错误。
最初我想要使用存储过程,但为了使它工作
我做了最简单的操作 - 没有成功...
你有什么想法吗?有什么问题?
问候
BR
Hi,
I''m trying to make a simple operation (insert into DB) in VB 2005 and SQL
Server.
The code is as follows:
Dim sConnectionString As String = _
"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\DB.mdf....
Dim cnDB As New SqlConnection(sConnectionString)
cnDB.Open()
Dim strSQL As String
strSQL = "INSERT INTO Company (CompanyName) VALUES (''four'')"
Dim command As SqlCommand = New SqlCommand(strSQL, cnDB)
command.ExecuteNonQuery()
cnDB.Close()
But the row is not inserted into DB and also there is no any error.
Initialy I wanted to use stored procedure but in order to make it working
I made the simplest operation - without success...
Do you have any idea what is wrong?
Regards
BR
ex消息显示没有(ex =无)并且没有插入行。
Just Me napisa3(a):
The ex message shows nothing (ex = nothing) and row is not inserted.
Just Me napisa3(a):
Dubug使用这个结构,看看ex.message的价值告诉你什么
尝试
''//你的代码
Catch ex as Exception''//断点在这里
结束尝试
" b_r" < b_r @ wp''_ cut_it''。plwrote in message
news:2d ************************* **@news.chello.pl。 ..
Dubug using this construct and see what the value of ex.message tells you
Try
''//Your Code
Catch ex as Exception ''//breakpoint here
End try
"b_r" <b_r@wp''_cut_it''.plwrote in message
news:2d***************************@news.chello.pl. ..
>
我正在尝试在VB 2005和SQL中进行简单的操作(插入到DB中)
服务器。
代码如下:
Dim sConnectionString As String = _
" Data
Source = .\ SQLEXPRESS; AttachDbFilename = | DataDirecto ry | \DB.mdf ....
Dim cnDB as new SqlConnection(sConnectionString)
cnDB.Open()
Dim strSQL As String
strSQL =" INSERT INTO Company(CompanyName)VALUES(''four'')"
Dim命令As SqlCommand = New SqlCommand(strSQL,cnDB)
command.ExecuteNonQuery()
cnDB.Close()
但是这行没有插入到DB中,也没有任何错误。
最初我想使用存储过程但是按顺序让它工作
我做了最简单的操作 - 没有成功......
你知道出了什么问题吗?
问候
BR
>Hi,
I''m trying to make a simple operation (insert into DB) in VB 2005 and SQL
Server.
The code is as follows:
Dim sConnectionString As String = _
"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirecto ry|\DB.mdf....
Dim cnDB As New SqlConnection(sConnectionString)
cnDB.Open()
Dim strSQL As String
strSQL = "INSERT INTO Company (CompanyName) VALUES (''four'')"
Dim command As SqlCommand = New SqlCommand(strSQL, cnDB)
command.ExecuteNonQuery()
cnDB.Close()
But the row is not inserted into DB and also there is no any error.
Initialy I wanted to use stored procedure but in order to make it working
I made the simplest operation - without success...
Do you have any idea what is wrong?
Regards
BR
''//这是正确的吗?是不是只是公司名称?
公司(公司名称)
strSQL =" INSERT INTO公司(CompanyName)VALUES(''''')" ;
" b_r" < b_r @ wp''_ cut_it''。plwrote in message
news:ca ************************* **@news.chello.pl。 ..
''// Is this correct ? should it not be just CompanyName ?
Company (CompanyName)
strSQL = "INSERT INTO Company (CompanyName) VALUES (''four'')"
"b_r" <b_r@wp''_cut_it''.plwrote in message
news:ca***************************@news.chello.pl. ..
ex信息显示什么(ex = nothing)并且没有插入行。
Just Me napisa3( a):
The ex message shows nothing (ex = nothing) and row is not inserted.
Just Me napisa3(a):
> Dubug使用这个结构,看看ex.message的价值告诉你什么
尝试
''//你的代码
抓住ex exception''//断点这里
结束尝试
" b_r" < b_r @ wp''_ cut_it''。plwrote in message
新闻:2d *************************** @ news .chello.pl ...
>Dubug using this construct and see what the value of ex.message tells you
Try
''//Your Code
Catch ex as Exception ''//breakpoint here
End try
"b_r" <b_r@wp''_cut_it''.plwrote in message
news:2d***************************@news.chello.pl ...
>>
我正在努力做一个简单的操作(插入到DB)在VB 2005和
SQL Server中。
代码如下:
Dim sConnectionString As String = _
" Data
Source = .\SQLEXPRESS; AttachDbFilename =| DataDirect ory | \DB.mdf ....
Dim cnDB as new SqlConnection(sConnectionString)
cnDB.Open()
Dim strSQL As String
strSQL =" INSERT INTO Company(CompanyName)VALUES(''four'')"
Dim命令As SqlCommand = New SqlCommand(strSQL,cnDB)
command.ExecuteNonQuery()
cnDB.Close()
但是这行没有插入到DB中,也没有任何错误。
最初我想要使用存储过程,但为了使它工作我做了最简单的操作 - 没有成功...
你有没有我知道出了什么问题吗?
BR
>>Hi,
I''m trying to make a simple operation (insert into DB) in VB 2005 and
SQL Server.
The code is as follows:
Dim sConnectionString As String = _
"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirect ory|\DB.mdf....
Dim cnDB As New SqlConnection(sConnectionString)
cnDB.Open()
Dim strSQL As String
strSQL = "INSERT INTO Company (CompanyName) VALUES (''four'')"
Dim command As SqlCommand = New SqlCommand(strSQL, cnDB)
command.ExecuteNonQuery()
cnDB.Close()
But the row is not inserted into DB and also there is no any error.
Initialy I wanted to use stored procedure but in order to make it
working I made the simplest operation - without success...
Do you have any idea what is wrong?
Regards
BR
这篇关于ExecuteNonQuery - 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!