Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert statement...

Status
Not open for further replies.

TPetersonFlorida

Programmer
Aug 8, 2003
76
US
I have a table where one of the columns is of 'text' data type. How do i insert a row into this table using the INSERT command? Also, how would you write a stored procedure to do this?

thanks in advance
todd
 
I use this for Inserting, Updating, and Deleting from tables. I dont know if it is the best way but it works well for me.


Dim conProcedure As New ADODB.Connection
Dim comProcedure As New ADODB.Command
Dim rstProcedure As New ADODB.Recordset

With conProcedure
.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Database Name;Data Source=ServerName"
.CursorLocation = adUseClient
.Open
End With

With comProcedure
.ActiveConnection = conProcedure
.CommandType = adCmdText
.CommandText = "INSERT INTO Table_T ([Column_1], [Column_2]) VALUES ('" & text1 & "' , '" & text2 & "'"
End With

Set rstProcedure = comProcedure.Execute
 
Thanks shannanl. But my question is not how to do this in ADO but how to create a stored procedure where you pass into it the values you want inserted. One of those values is for a column defined as a text type. I can't seem to find anything when it comes to this.
 
Same as any other.
You may have problems if you want to pass more than 8000 chars (or 255) though depending on the provider.

Create proc ins
@s text
as

insert tbl (txt) select @s
go


======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top