PLC isimli pc'mizde WINCC adlı SQL server var ve bunun icerisinde table1 isimli tablo oluşturduk. Tabloya 2 adet satır oluşturduk. Aşağıdaki kodu bir buton icerisine yerleştririp calıştırınız. okunandeger$ adlı değişkene 2. satırda yazılı olan değer atanmış olacaktır.
Kod:
Dim objConnection Dim objRecordset Set objConnection = CreateObject("ADODB.Connection") objConnection.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=deneme;Data Source=PLC\WINCC" objConnection.Open Set objRecordset = CreateObject("ADODB.Recordset") Set objRecordset.ActiveConnection = objConnection objRecordset.CursorType = 1 objRecordset.LockType = 3 objRecordset.Open "select * From table1" objRecordset.movenext okunandeger$ = objRecordset.fields(0).Value objConnection.Close Set objRecordset = Nothing Set objConnection = Nothing
Kolay gelsin.
__________________
ADODB ile Database'den Okuma Yapmak
Programlama0 Mesaj
●28 Görüntüleme
- ReadBull.net
- Programlama ve Yazılım
- Programlama
- ADODB ile Database'den Okuma Yapmak