关于字段类型问题,存入太多数据出错
数据表有一字段为content(新闻内容),字段类型为ntext,长度为16
存储过程为:
create proc add_news
@strsubject nvarchar(100),/*新闻标题*/
@newstype nvarchar(100),/*新闻类型*/
@strfrom nvarchar(100),/*新闻出处*/
@author nvarchar(100),/*新闻作者*/
@editor nvarchar(100),/*新闻编辑*/
@newskey nvarchar(100),/*新闻关键字*/
@content ntext,/*新闻内容*/
@ptime datetime,
@filepath nvarchar(100)
as
insert into news(strsubject,newstype,strfrom,author,editor,newskey,content,ptime,filepath)
values(@strsubject,@newstype,@strfrom,@author,@editor,@newskey,@content,@ptime,@filepath)
GO
-----------------
问题就出在下面这句了,当我录入内容太长的时候,5万字左右,就报错
Cmd1.CreateParameter( "@content ",adLongVarWChar,adParamInput,500000,content)
要怎么改呢?是不是要改adLongVarWChar?这个500000能不能改成其他的?谢谢
------解决方案--------------------ntext都不行?
------解决方案--------------------请看我的测试:
表:
create table testAAAA(a int,b ntext)
insert testAAAA select 1, '23094823 '--插第一条数据
存储过程:
create proc testProcc
@a int,
@b ntext
as
insert testAAAA select @a,@b
vb程序:
Private Sub Command1_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim comm As String
con.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;pwd=pass;Initial Catalog=test;Data Source=DB "
con.Open
Open "d:\test.txt " For Binary As #1--test.txt中的字符有75万
comm = Input$(LOF(1), #1)
Close #1
cmd.ActiveConnection = con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "testProcc "
cmd.Parameters.Append cmd.CreateParameter( "@a ", adInteger, adParamInput, 8, 1000)
cmd.Parameters.Append cmd.CreateParameter( "@b ", adLongVarWChar, adParamInput, -1, comm)
cmd.Execute
End Sub