Hello
Here's an more detailed example. You need to edit the connection settings and the sql string.
Can you explain more in detail what you want to do?
AddReference "System.Data.dll"
Imports System.Data.SqlClient
Sub main
'ENTER your connection settings here
Dim sConn As String = String.Empty
sConn="server=$SERVERADDRESS;uid=$USERNAME;pwd=$PASSWORD;database=$DATABASENAME"
'Enter Tablename and values to insert
'If there are less values than columns in your table, you need to specify wich value corresponds to which column
Dim sql As String = String.Empty
sql = "Insert into $TABLENAME values('" & strValue1 & "','" & strValue2 & "','" & strValue3 & "','" & strValue4 & "')"
If ExtSql(sConn, sql) Then
MsgBox("Command executed", MsgBoxStyle.Information, "iLogic")
End If
End Sub
Function ExtSql(ByVal sConn As String, ByVal sql As String) As Boolean
Dim cnn As SqlConnection
Dim cmd As SqlCommand
cnn = New SqlConnection(sConn)
Try
cnn.Open()
cmd = New SqlCommand
cmd.Connection = cnn
cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = sql
cmd.ExecuteNonQuery()
cnn.Close()
cmd.Dispose()
Catch ex As Exception
cnn.Close()
Return False
End Try
Return True
End Function
R. Krieg
RKW Solutions
www.rkw-solutions.com