INTERPOLL
01-09-2004, 10:35 PM
can anyone help me\ how to add a new record to the database by commandbutton in my project ??
this is my code :
visual basic code:--------------------------------------------------------------------------------Public Function DataAnalyzing(Result As String) As ADODB.Recordset
Dim RS As New ADODB.Recordset
Dim Pos As Long
Dim CommaPos As Long
Dim t As Integer
Dim y As Integer
Dim FieldsNum As Integer
Dim RecordsNum As Integer
Dim * * * As String
* * * = "Fields:"
Pos = InStr(1, Result, * * *)
CommaPos = InStr(Pos, Result, ";")
FieldsNum = Val(Mid(Result, Pos + Len( * * *), CommaPos - Pos - Len( * * *) + 1))
Pos = CommaPos + 1
For t = 0 To FieldsNum - 1
CommaPos = InStr(Pos, Result, ";")
RS.Fields.Append Mid(Result, Pos, CommaPos - Pos), adWChar, 50
Pos = CommaPos + 1 'detect the next first field name
Next t
* * * = "Records:"
Pos = InStr(Pos, Result, * * *)
CommaPos = InStr(Pos, Result, ";")
RecordsNum = Val(Mid(Result, Pos + Len( * * *), CommaPos - Pos - Len( * * *) + 1))
Pos = CommaPos + 1
RS.Open
For y = 1 To RecordsNum
RS.AddNew
For t = 0 To FieldsNum - 1
CommaPos = InStr(Pos, Result, ";")
RS.Fields(t) = Mid(Result, Pos, CommaPos - Pos)
Pos = CommaPos + 1 'detect the next first letter of data
Next t
RS.Update
Next y
Set DataAnalyzing = RS
End Function
Private Sub Command1_Click()
Result = Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=connect&user=" & Text1.Text & "&pass=" & Text6.Text)
If InStr(1, Result, "connect ok") Then
Text5.Text = "ur connected"
Else
Text5.Text = "ur not connected"
End If
End Sub
Private Sub Command2_Click()
Result = Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=select&data=" & Text2.Text)
End Sub
Private Sub Command3_Click()
Result = Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=crate&data=" & Text3.Text)
If InStr(1, Result, "ok") Then
Text5.Text = "db created"
Else
Text5.Text = "sorry db exist"
End If
End Sub
Private Sub Command4_Click()
Result = Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=drop&data=" & Text4.Text)
If InStr(1, Result, "ok") Then
Text5.Text = "db deleted"
Else
Text5.Text = "db not deleted"
End If
End Sub
Private Sub Command5_Click()
Set grdShowData.Recordset = DataAnalyzing(Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=select_table"))
End Sub
--------------------------------------------------------------------------------
my site url = http://members.lycos.co.uk/alsa3di
ftp name : alsa3di
password : alsaedi2000
there r 3 php files in the folder (data)
and the project also .
please help meeeeeeeeeplease help meeeeeeeee
this is my code :
visual basic code:--------------------------------------------------------------------------------Public Function DataAnalyzing(Result As String) As ADODB.Recordset
Dim RS As New ADODB.Recordset
Dim Pos As Long
Dim CommaPos As Long
Dim t As Integer
Dim y As Integer
Dim FieldsNum As Integer
Dim RecordsNum As Integer
Dim * * * As String
* * * = "Fields:"
Pos = InStr(1, Result, * * *)
CommaPos = InStr(Pos, Result, ";")
FieldsNum = Val(Mid(Result, Pos + Len( * * *), CommaPos - Pos - Len( * * *) + 1))
Pos = CommaPos + 1
For t = 0 To FieldsNum - 1
CommaPos = InStr(Pos, Result, ";")
RS.Fields.Append Mid(Result, Pos, CommaPos - Pos), adWChar, 50
Pos = CommaPos + 1 'detect the next first field name
Next t
* * * = "Records:"
Pos = InStr(Pos, Result, * * *)
CommaPos = InStr(Pos, Result, ";")
RecordsNum = Val(Mid(Result, Pos + Len( * * *), CommaPos - Pos - Len( * * *) + 1))
Pos = CommaPos + 1
RS.Open
For y = 1 To RecordsNum
RS.AddNew
For t = 0 To FieldsNum - 1
CommaPos = InStr(Pos, Result, ";")
RS.Fields(t) = Mid(Result, Pos, CommaPos - Pos)
Pos = CommaPos + 1 'detect the next first letter of data
Next t
RS.Update
Next y
Set DataAnalyzing = RS
End Function
Private Sub Command1_Click()
Result = Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=connect&user=" & Text1.Text & "&pass=" & Text6.Text)
If InStr(1, Result, "connect ok") Then
Text5.Text = "ur connected"
Else
Text5.Text = "ur not connected"
End If
End Sub
Private Sub Command2_Click()
Result = Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=select&data=" & Text2.Text)
End Sub
Private Sub Command3_Click()
Result = Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=crate&data=" & Text3.Text)
If InStr(1, Result, "ok") Then
Text5.Text = "db created"
Else
Text5.Text = "sorry db exist"
End If
End Sub
Private Sub Command4_Click()
Result = Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=drop&data=" & Text4.Text)
If InStr(1, Result, "ok") Then
Text5.Text = "db deleted"
Else
Text5.Text = "db not deleted"
End If
End Sub
Private Sub Command5_Click()
Set grdShowData.Recordset = DataAnalyzing(Inet1.OpenURL("http://members.lycos.co.uk/alsa3di/data/check.php?code=select_table"))
End Sub
--------------------------------------------------------------------------------
my site url = http://members.lycos.co.uk/alsa3di
ftp name : alsa3di
password : alsaedi2000
there r 3 php files in the folder (data)
and the project also .
please help meeeeeeeeeplease help meeeeeeeee