'Using ADO control to create a database table from Visual Basic
'Connect to the database file and use the Connection object's Execute method to
'execute an SQL CREATE TABLE statement.
Private Sub BtnCreate_Click()
Dim db_file As String
Dim Conn_Data As ADODB.Connection
Dim rs_Data As ADODB.Recordset
Dim num_records As Integer
' Get the database name.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
db_file = db_file & "People.mdb"
' Open a Conn_Dataection.
Set Conn_Data = New ADODB.Connection
Conn_Data.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & db_file & ";" & _
"Pers_Dataist Security Info=False"
Conn_Data.Open
' Drop the Employees table if it already exists.
On Error Resume Next
Conn_Data.Execute "DROP TABLE Employees"
On Error GoTo 0
' Create the Employees table.
Conn_Data.Execute "CREATE TABLE EmployeesTable(" & "EmployeeId INTEGER NOT NULL," & _
"LastName VARCHAR(40) NOT NULL," & "Firs_DatatName VARCHAR(40) NOT NULL)"
' Populate the table.
Conn_Data.Execute "INSERT INTO EmployeesTable VALUES (1, " & "'Anders_Dataon', 'Amy')"
Conn_Data.Execute "INSERT INTO EmployeesTable VALUES (1, 'Baker', " & " 'Betty')"
Conn_Data.Execute "INSERT INTO EmployeesTable VALUES (1, 'Cover', " & " 'Chauncey')"
' Add more records ...
' See how many records the table contains.
Set rs_Data = Conn_Data.Execute("SELECT COUNT (*) FROM EmployeesTable")
num_records = rs_Data.Fields(0)
Conn_Data.Close
MsgBox "Created " & num_records & " records", vbInformation, "Done"
End Sub
22 comments:
Impressive as always
The ADO brings me back !
Public Sub CLIENT_EXP(S_Date As String, C_Num As String)
Dim LCJ As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As New ADODB.Command
Set LCJ = New ADODB.Connection
strConnect = "DSN=TM9VBA;Uid=tm9user;Pwd=R1234xa.;"
cmd.CommandText = "Select mat_no, usr1_04_01, USR1_04_02, USR1_04_03, USR1_04_04, USR1_02_08 from timematters9.tm9user.usertype3 where CONVERT(CHAR,DATEADD(D, date, '1800-12-28'),101) >= '" & S_Date & "' and con_no = '" & C_Num & "'"
LCJ.ConnectionString = strConnect
LCJ.Open
Set cmd.ActiveConnection = LCJ
Set rs = New ADODB.Recordset
'Set rs = cmd.Execute
rs.Open cmd.CommandText, LCJ, adOpenKeyset, adLockOptimistic
Dim ArrMn() As String, ArrInj() As String, ArrDoa() As String, ArrDs() As String, ArrDe() As String, ArrCst() As String, ArrCde() As String
Dim reccnt
reccnt = rs.RecordCount
ReDim ArrMn(0 To reccnt)
ReDim ArrInj(0 To reccnt)
ReDim ArrDoa(0 To reccnt)
ReDim ArrDs(0 To reccnt)
ReDim ArrDe(0 To reccnt)
ReDim ArrCst(0 To reccnt)
ReDim ArrCde(0 To reccnt)
Dim m As Integer
m = 0
Do Until rs.EOF
ArrMn(m) = rs(0).Value
ArrInj(m) = rs(1).Value
ArrDoa(m) = rs(2).Value
ArrDs(m) = rs(3).Value
ArrDe(m) = rs(4).Value
ArrCst(m) = rs(5).Value
ArrCde(m) = rs(6).Value
rs.MoveNext
m = m + 1
Loop
End Sub
This stuff used to drive me nuts
!
Well, we had this topic on ADO Control to create Database Table using Visual Basic in our graduation studies. This article has doubled my knowledge. Thanks for sharing.
nice share.. :)
keep posting
Thank you for your post, You are given the step by step process and code for visual basic.net..thank you.. i will try your code..
Cegonsoft
plz mujhe visul basic k source code bata do urdu me
i using visual basic 2010 ultimate to create a database. and i doing a project using c# in vb studio 2011....can anyone tell me how to link the database into project tat i create.....so that it can function....
I am learning database and visual basic. This information is very useful for me. The code for creating database table using Visual Basic is given in simple language. The code easy to understand. Is it possible to show the source code to connect database to any application?
activex codes
https://bayanlarsitesi.com/
Cihangir
Heybeliada
Yalova
Adana
32XK
Afyon
Balıkesir
Kırklareli
Amasya
Bilecik
MHR
Elazığ
Kocaeli
Nevşehir
Erzurum
Bilecik
7CK
Bolu Lojistik
Mardin Lojistik
Kocaeli Lojistik
Diyarbakır Lojistik
İstanbul Lojistik
OKV
B10DD
Hakkari Parça Eşya Taşıma
Afyon Parça Eşya Taşıma
Sivas Lojistik
Adana Lojistik
Osmaniye Evden Eve Nakliyat
266AB
Denizli Parça Eşya Taşıma
Burdur Parça Eşya Taşıma
Gümüşhane Şehirler Arası Nakliyat
Batman Şehir İçi Nakliyat
Tokat Parça Eşya Taşıma
Manisa Parça Eşya Taşıma
Antep Evden Eve Nakliyat
Muş Evden Eve Nakliyat
Sivas Şehirler Arası Nakliyat
Üniversiteler öğrencilerin kendilerini geliştirdikleri en önemli yerdir. Bu üniversiteler tüm dünyada binlerce farklı alanda da eğitim vermektedir. Harran Üniversitesi Tanıtım bunlardan biri olarak yer almaktadır. Yine aynı şekilde doğu illerimizden birinde yer alan Bingöl ilimizde de Bingöl Üniversitesi Tanıtım yazısı yer almaktadır. Bu yazılardan bilgi alabilirsiniz. Bu site oldukça kaliteli içerikler sunmaktadır. Göz atmakta fayda var.
Aotons Kick Rail can prevent the forklift truck from passing through and colliding from the bottom, and can be used as the ground pallet storage or the limiter of forklift truck. It can also be integrated into the traffic barrier or pedestrian safety barrier system. According to the impact test, it can resist the impact of 6-ton forklift at the speed of 5km/h without damage.
As a cylinder packaging manufacturer with over 10 years of experience, Hopak custom electronic packaging with high-quality paper tubes. Whether you sell electronics or electronics parts, Hopak packaging tubes for electronics will represent the value of your brand. Different from other suppliers, Hopak only utilizes first-class paper material to keep your fragile electronic products safe from scratches and damage in general. Create a functional and good-looking electronic packaging solution that will display your advanced tech.
Linkotest offers PC-controlled pneumatic shock testers known as Bump Test Machines. These machines are designed to ensure accurate and repeatable shock testing for both laboratory and production environments. They are capable of testing samples weighing up to 1000 kg (depending on the model).
Equipped with shock pulse programmers, these machines can generate short and long duration half sine shock pulses. This functionality allows them to meet strict automotive, military, and industrial specifications, as well as customized testing requirements. The generated waveforms comply with various military standards, such as MIL-STD-202, MIL-STD-750, MIL-STD-810, and MIL-STD-883.
The low voltage motor control center (MCC) is an integrated electrical control equipment used to start, stop, and protect motors. It provides centralized control and power distribution for motors in industrial and commercial applications. The low voltage MCC consists of a frame, busbars, circuit breakers, starters, control devices, interlocking devices, cable ducts, etc.
BM2508-SE es un fabricante de cajas multifuncional Máquina de caja corrugada
completamente automático con ranurado y marcado horizontal, corte y plegado vertical, corte horizontal, todo en una máquina compacta. En comparación con el modelo BM2508-Plus, el modelo BM2508-SE es una máquina de versión económica, que es de gran importancia para todos los usuarios bajo la epidemia. Para reducir el presupuesto y los gastos, está equipada con un alimentador de borde delantero de 900 mm, 2 ruedas de hendido verticales y un módulo de troquelado de orificio de mano retirado.
5E637C6381
telegram show
Post a Comment