Sorry guy, I am from VB.Net i will provide u the code in vb.net
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As Integer, ByVal ByValfRequest As Integer, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Integer
Private Const vbAPINull As Integer = 0 ' NULL Pointer
Private Const ODBC_ADD_DSN As Short = 1 ' Add data source
Public Sub CreateUserDSN()
Try
Dim intRet As Integer
Dim Driver As String
Dim Attributes As String
'Set the driver to SQL Server because it is most common.
Driver = "SQL Server"
'Set the attributes delimited by null.
'See driver documentation for a complete
'list of supported attributes.
Attributes = "SERVER=zsw327" & Chr(0)
Attributes = Attributes & "DATABASE=KFI" & Chr(0)
Attributes = Attributes & "DESCRIPTION=New DSN" & Chr(0)
Attributes = Attributes & "DSN=KFIDSN" & Chr(0)
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, Driver, Attributes)
If intRet <> 0 Then
MsgBox("DSN Created")
Else
MsgBox("Create Failed")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub