Help in Database connectivity in VB 6.0

Status
Not open for further replies.

redhat

Mad and Furious
Hi Guys,
I am currently working on a aproject in VB 6.0. I am connecting VB to SQL 2000 using the ADODC recordset. I want to enter values into the database table, via a SQL string. Please tell me how to do this. I am new to VB and wil require a small explanation. But that will do.
 

sweetricha07

Broken In
I have no ideas about d/b connectivity in SQL 2000 but I did a project connecting VB 6.0 with Oracle 8i. If you want i can help you with that.
 

gr8usr

Broken In
ignore the winsock parts in the code...
if u dont understand anything i ll explain


Dim s As String
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Winsock1(Index).GetData s, vbString
db = Split(s, "~~")(0)
op = Split(s, "~~")(1)
roll = Split(s, "~~")(2)
nam = Split(s, "~~")(3)
marks = Split(s, "~~")(4)
If op = "add" Then
If db = "oracle" Then
con.Open orastr, "adi", "adi"
Dim a As String
a = "insert into student values (" & roll & "," & nam & "," & marks & ")"
rs.Open a, con
con.Close
Winsock1(Index).SendData ("Success")
ElseIf db = "access" Then
con.Open accstr
Dim ab As String
ab = "insert into student values ('" & roll & "','" & nam & "','" & marks & "')"
rs.Open ab, con
con.Close
Winsock1(Index).SendData ("Success")
End If
ElseIf op = "delete" Then
If db = "oracle" Then
con.Open orastr, "adi", "adi"
Dim abc As String
abc = "delete from student where roll=" & roll
rs.Open abc, con
con.Close
Winsock1(Index).SendData ("Success")
ElseIf db = "access" Then
con.Open accstr
Dim abcd As String
abcd = "delete from student where roll=" & roll
rs.Open abcd, con
con.Close
Winsock1(Index).SendData ("Success")
End If
ElseIf op = "view" Then
If db = "oracle" Then
con.Open orastr, "adi", "adi"
rs.Open "select * from student", con
Winsock1(Index).SendData (rs)
con.Close
ElseIf db = "access" Then
con.Open accstr
rs.Open "student", con
' Winsock1(Index - 1).SendData rs
Winsock1(Index).SendData (rs)
'Winsock1(Index + 1).SendData rs
con.Close
End If

End If
 

Manshahia

Resident Fanatic
Hey REDHAT,
recently i was also working on a visual basic project.
I downloaded about 150 projects in VB to check how other ppl do the connectivity.
And from all those projects i hav made mine a small and having easy code that can also b learnt very easily.
If u want that project i can send u.
Just mail me ur ID at ravinder_manshahia@yahoo.com
 
Status
Not open for further replies.
Top Bottom