Friday, December 30, 2011

Adding New Record : ODBC Connection in Notes

It is similar to creating ODBC connection in java.

Create a agent for Adding new record to MS-Access

Step1: Create a connection to ODBC for accessing database.

Step2: Mention the name of the table and get a query for insert record.

step3: Call this agent from view.

Sample coding:

Dim con As New ODBCConnection ‘ Declare con object for connect to database.

Dim qry As New ODBCQuery ‘Declare qry variable as ODBCQuery

Dim res As New ODBCResultSet ‘Declare res for get the records

Dim i As Integer

Dim b As Boolean

If Con.ConnectTo(”DBs”) Then ‘Here create a connection to data source

Set Qry.Connection = Con

Qry.SQL = “select * from stdu1″ ‘Create a query for get all records from table

Set Res.Query = Qry



Res.addrow ‘Create a object for adding new record

‘Add new value to specified Column

Call res.Setvalue(”RollNo”,CInt(InputBox(”Enter Roll No”,”")))

Call res.setvalue(”Name”,InputBox(”Enter name”,”"))

MsgBox (”The given row was succesfully added.”)

Call res.Updaterow() ‘Here refresh the table after adding new values

i=ws.Prompt(2, “New Record”, “Do you want to add new record”)

If i=1 Then

GoTo addnew ‘User want to add new record again then repeat the above processes

End If

Res.Close(DB_Close) ‘Close the result set

con.DisConnect ‘Here disconnect the existing connection


MessageBox (”Could not connect to data source”)

End If

No comments:

Post a Comment