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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL INSERT

Status
Not open for further replies.

morlassino

IS-IT--Management
Jul 1, 2004
33
0
0
US
what is wrong with this
Code:
SqlString = "insert into brkdetails(busno) values('548')"
Adodc1.RecordSource = SqlString
Adodc1.Refresh
it inserts but i get error that can't while not open....



MARIO P ORLASSINO
ASSISTANT MANAGER IT
 
Do NOT use the adodc data control.
Declare a ADO connection independently, and then use either the connection or the command object to do inserts.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Frederico beat me to it!

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
I AM SORRY I may sound stupid i am new to VB
what should i do something like this...

Code:
Set SQLSTRING = New ADODB.Connection

SQLSTRING = "insert into brkdetails(busno) values('548')"
Adodc1.RecordSource = SQLSTRING

MARIO P ORLASSINO
ASSISTANT MANAGER IT
 
Search these forums/FAQ's for ADO and connection and you will find some examples, including one FAQ that does exactly what you need (though using parameters).

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
i am still having problems...
i have tried many different things
Code:
dim cn as new adodb.connection
cn = "insert into brkdetails(date) values('11/6/04')
cn.execute
cn.close

can anyone help please!!

MARIO P ORLASSINO
ASSISTANT MANAGER IT
 
You are missing some code on you sample.
Please put you FULL code, not just snippets.

You should offcourse remove everything that is not related to the ADO. e.g. form related code is not required.


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Code:
Private Sub ADD_Click(Index As Integer)
Dim oconn As New ADODB.Connection
oconn.Open "Provider=sqloledb;" & _
           "Data Source=dc-devlp01-srv/hcc_sql_srv;" & _
           "Initial Catalog=breakdownsvb1104;" & _
           "Integrated Security=SSPI"

oconn = "insert into brkdetails(busno) values('888')"
End Sub


MARIO P ORLASSINO
ASSISTANT MANAGER IT
 
thank you i think i finally got it..


MARIO P ORLASSINO
ASSISTANT MANAGER IT
 
Mario, I use the following for SQL statements, it works well for me:

Dim conDetails As New ADODB.Connection
Dim comDetails As New ADODB.Command
Dim rstDetails As New ADODB.Recordset

With conDetails
.ConnectionString = "Provider=SQLOLEDB.1;
Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=
YourDatabaseName;Data Source=
YourDatabaseServerName"
.CursorLocation = adUseClient
.Open
End With

With comDetails
.ActiveConnection = conDetails
.CommandType = adCmdText
.CommandText = "SQL Statement"
End With

Set rstDetails = comDetails.Execute

Hope this helps.

Shannan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top