Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




ADODC1.Connectionstring


hi,im currently working on a database program using VB and MS Access.im using adodc and its datagrid object to load and view records.I'D VERY MUCH want to use:

ADODC1.Connectionstring = "Provider***etc.***;DataSource= " & App.Path & " Databasemydatabase.mdf"

...so that i could just move the program along with the database file (since i've placed them in a single folder) to another location, like another pc, and load the program with no error coming out like:

Error: "C:MyprogramDatabasemydatabase.mdf' is an invalid source path!"

By using ADO instead of DAO, i know that i could solve this but im trying to avoid using MSHFlexgrid (which they say is supported by ADO) cause im having problems using it.If i leave the ADODC Connectionstring property blank on the properties table and just implement the connectionstring on code, an invalid format issue error occurs. Assuming that I NEVER use DAO, is there a way to solve this matter?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
What Is The Diference Between Adodc1.Recordset.EOF && Adodc1.Recordset.BOF
What is the diference between Adodc1.Recordset.EOF & Adodc1.Recordset.BOF

ADODC1 And SQL
I have a database with several tables. On the main form of my project I have several buttons to call other forms each of which has data from a different table of the database. I need the form that is called to bring up the data for the individual by using the ID fields. If the main form's id field contains the number 23, I need the called form to show the info for the record ID 23. I'm using ADODC data controls. I know that it's not a good thing to use controls but under the circumstances I must. In the data controls property I have it set for "adcmdtext" with this sql statment

select * from clients where txtRpt_Client_ID.text = frmsecurity.txtguestid.text

I get error messages. Can anyone help?

Adodc1 And Flexgrid
I have a problem, when i want to delete a row that has a duplicate row in mshflexgrid1, i get a too many columns affected. How do i stop this error either through code or error handeling. I can post code if needed, just trying to keep thread shorter.

Adodc1 Or Data1?
i want in my program to search for certain fields inside a database table and if I've entered CORRECTLY one of them it should chack if it is true and continue.

like a login form.please give me some suggestions.
thanks

Adodc1 Error
I created a vb app on my local machine. now i wnat to deploy it over my network. But the problem with im faced with is everyon at my company has different drive letters mapping to the same network path. i set it up on the I: drive and some people have F:,G: they all point to the same server....My databse resides on our development server, but everyone maps with different drive letters????

Much help neeeded how can i tell vb to find say a ip adress network folder?

Adodc1 Problem
im getting this error when i press the command button to get to a datagrid form:

Adodc1

No value given for one or more required parameters

what does this mean and how can it be fixed?

ADODC1 App.Path
I have done a search on this but I still can't seem to get it to work. Sorry if this has been covered before.

When I started this project I used data bound controls. Lebb has tought me better now. So now I have some forms that still have adodc on them with the path hard coded. I want to use App.Path. but I can't seem to get it right.

I have tried to set the connetion string at form load, using my sConn, that is working fine with my coded connections. Which is:

sConn = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & App.Path & "llu.mdb" & ";Persist Security Info=False"

What do I do with the connection string that is in the ADODC Properties? I have tried to leave the datasource blank, get an error. I have tried to leave the whole connection string blank. that didnt work.

Can someone point me in the right direction, I'm lost, AGAIN!

Thanks

ADODC1 Addnew
I want to add some records to a mdb with adodc1 but I don't know how!
The code that I tryed is:

Adodc1.recordset.addnew
adodc1.recordset.fields(1)="dddddddd"
adodc1.recordset.update

When I'm trying to run the code I receive an error like:

Object variable not defined ...

PLease helllllllllllllllp!

Adodc1.caption
OK a simple one but can't figure it out sorry.
I want to place the current record out total records in the Adodc1.caption,
i.e 116, 216, 316 etc....
and change when skipping through records.
I know the bit to show total records,

Code:
Adodc1.Caption = Adodc1.Recordset.RecordCount
but not the first?

ADODC1 && Datagrid
I am wondering what files does adodc1 and datagrid controls need because I am running XP and ADODC1 populates the datagrid fine.

But when I test it under a new W98/2K installation the datagrid doesn't get populated and no errors are given.

Any ideas?

Adodc1 Search
Can anyone help me please.

the problem is that see once i search for a record how do i get it so it only shows the records fields in the text boxes instead of changeing the datagrid so it only shows the one i searched for and keep the other records in the datagrid? I have the datagrid linked to the ADODC1 control aswell.


VB Code:
Adodc1.RecordSource = "Select * from secretary where club = """ & txtSearch.Text & """"Adodc1.Refresh

Adodc1 Problem
Can anyone help me please.

When i try and run the program it says

Syntax error in FROM clause



Can anyone help me please.

ADODB ADODC1 To 9
Question i have many connections and recordsets

i have been using the data control for collecting data, is there any limit on how many data controls i have in a project?

also im getting a strange error on one error 545 unable to bind to field item, any ideas?

thanks in advance

ADODC1 Search
OK I know this has been posted before but I am having serious troubles with it. I have written an application to search a Access 2000 database for a keyword (inputted by user). I would like my results to be displayed in a datgrid. Here is my code:


Private Sub cmdSearch_Click()

'Call_Logs is my database table name
'Call_Description is my field name in the above table
'txtSearch.Text is input on a form by the user

Dim mySql As String
Dim ConStr As String
Item = Trim(txtSearch.Text)

mySql = "select * from Call_Logs where Call_Description = " & Item

Adodc1.CommandType = adCmdText
Adodc1.RecordSource = mySql
'Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1.Recordset

what am I doing wrong? When I run this code I get no results. My datagrid still shows all entries in the table.

Thanks in advance for your help

ADODC1 Search
OK I know this has been posted before but I am having serious troubles with it. I have written an application to search a Access 2000 database for a keyword (inputted by user). I would like my results to be displayed in a datgrid. Here is my code:


Private Sub cmdSearch_Click()

'Call_Logs is my database table name
'Call_Description is my field name in the above table
'txtSearch.Text is input on a form by the user

Dim mySql As String
Dim ConStr As String
Item = Trim(txtSearch.Text)

mySql = "select * from Call_Logs where Call_Description = " & Item

Adodc1.CommandType = adCmdText
Adodc1.RecordSource = mySql
'Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1.Recordset

what am I doing wrong? When I run this code I get no results. My datagrid still shows all entries in the table.

Thanks in advance for your help

Adodc1 Problem
im getting this error when i press the command button to get to a datagrid form:

Adodc1

No value given for one or more required parameters

what does this mean and how can it be fixed?

command button code:



VB:
--------------------------------------------------------------------------------
Private Sub Score_Click()
Form1.Visible = True
On Error Resume Next
    sbConnectADO
    With rs
        .Open "SELECT * FROM colour", dbs, adOpenDynamic, adLockPessimistic, adAsyncFetch
        .AddNew
        !StartTime = sTime
        !EndTime = Now
        !PlayerName = gstrUserName
        .Update
    End With
    sbCloseADO
    
End Sub

--------------------------------------------------------------------------------



module code


VB:
--------------------------------------------------------------------------------
Option Explicit

Public gstrCurrentPlayer As String

Dim sNewTime As String
Public sTime As String
Public rs As ADODB.Recordset
Public dbs As ADODB.Connection

Public Sub sbConnectADO()
    Set dbs = New ADODB.Connection
    Set rs = New ADODB.Recordset

    With dbs
        .CursorLocation = adUseClient
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .Open App.Path & "colouring.mdb", "admin", ""
    End With
    
End Sub

Public Sub sbCloseADO()
    rs.Close
    dbs.Close
    Set rs = Nothing
    Set dbs = Nothing
End Sub
--------------------------------------------------------------------------------

Adodc1 And Sql Statements1
how to add adodc 1 and sql statements in visual basic

coz iam creating a changing username and password forms

how to check if there is an existing one and will not accept it but if there is none it will accept it

 

ADODC1 Provider Cannot Be Found
Cannot figure out what obj files or .dll's are regired when packaging program for use on another xp computer. Works OK on one with vb6 loaded. I have downloaded latest Mdac_typ page and still comes up with 'provider cannot be found.

Any help!
thanks Richie

ADODC1 Movenext Event???
I have a VB form with a Adodc control and a few fields. I would like to run an event every time the user clicks the arrows on the control.

Any ideas?

Adodc1 Provider Cannot Be Found
Cannot figure out what obj files or .dll's are regired when packaging program for use on another xp computer. Works OK on one with vb6 loaded. I have downloaded latest Mdac_typ page and still comes up with 'provider cannot be found.

Any help!
thanks Richie

Adodc1 && Flexgrid Problems
I cannot for the life of me figure this out. I using Access DB and Mshflexgrid1. Everything is set up right basically, but i cant figure out how to stop the EOF and BOF errors. Also when i try to delete the record on the bottom of flexgrid it deletes the one before it. Anyone please help!

[vb]
Private Sub alpha()
mshflexgrid1.Sort = flexSortGenericAscending

End Sub
Private Sub delstatus()
If ADodc1.Recordset.RecordCount = 0 Then CmdDelete.Enabled = False
If ADodc1.Recordset.RecordCount > 0 Then CmdDelete.Enabled = True
End Sub
Private Function delete()

With ADodc1.Recordset

.Move (mshflexgrid1.RowSel - 1)
.delete
.Requery
End With

ADodc1.Refresh

Call delstatus
Call NUMFILES
Call alpha
End Function
Private Function NUMFILES()
Dim NUM As String
Lblfiles.Caption = ADodc1.Recordset.RecordCount
End Function

Private Sub Cleartext()
TxtFIRST = " "
TxtLAST = " "
TxtADDRESS = " "
TxtCITY = " "
TxtSTATE = " "
TxtZIP = " "
TxtPHONE = " "
txtCELL = " "
TxtEMAIL = " "
txtcomment = " "
End Sub

Private Sub CmdADD_Click()

With ADodc1.Recordset
.AddNew
!First = TxtFIRST

!Last = TxtLAST
!Address = TxtADDRESS
!city = TxtCITY
!State = TxtSTATE
!zip = TxtZIP
!phone = TxtPHONE
!cell = txtCELL
!email = TxtEMAIL
!Comments = TxtCOMMENTS
.Update
.Requery
End With


ADodc1.Refresh
Set mshflexgrid1.DataSource = ADodc1
Call delstatus
Call NUMFILES
Call Cleartext
Call reset
End Sub


Private Sub CmdHome_Click()
End
End Sub



Private Sub Form_Load()
If ADodc1.Recordset.RecordCount = 0 Then CmdDelete.Enabled = False
With mshflexgrid1
.ColWidth(0) = 1000
.ColWidth(1) = 1000
.ColWidth(2) = 1700
.ColWidth(3) = 700
.ColWidth(4) = 600
.ColWidth(5) = 650
.ColWidth(6) = 1300
.ColWidth(7) = 1300
.ColWidth(8) = 2200
End With
Call NUMFILES
Call alpha
Call Cleartext

End Sub

Private Sub Cmddelete_Click()
ans = MsgBox("Are You Sure You Want to Delete This Item?", vbYesNo, "Delete Confirm!")
If ans = vbYes Then
With ADodc1.Recordset

.Move (mshflexgrid1.RowSel + 1) ' we minus one because row zero is the header row
.delete
.Requery
End With

ADodc1.Refresh
Set mshflexgrid1.DataSource = ADodc1
Call delstatus
Call NUMFILES
Call alpha

Call reset
Call delete
Call alpha
End If
End Sub


Private Sub mshflexgrid1_click()
If mshflexgrid1.MouseRow = 0 Then
mshflexgrid1.Col = mshflexgrid1.MouseCol
lngSortCol = mshflexgrid1.Col

blnAscendingSort = Not blnAscendingSort
If blnAscendingSort Then
mshflexgrid1.Sort = flexSortGenericAscending
Else
mshflexgrid1.Sort = flexSortGenericDescending

End If
End If
End Sub

[vb]

Adodc1.recordset.move
does anyone know what code should follow this:
adodc1.recordset.move ?
thanks

DBCombo Box With Adodc1 And Data1
Hi all,

I just can't seem to get my dbcombo box to work correctly.

If I use a DAO object (data1) and try to map my access 2000 database to it, it comes up with an error when I try to set the property.

If I use an ADO object (adodc1) I can connect to the database with a system DSN via my dbcombo box oblect and select the data source, I have 'data source' fields viewable and can select them, however, when I try to select the 'list field' property, it is empy and therefore I am unable to use the dbcombo box to select an item.

Could someone please offer assistance?

Adodc1 && Datagrid Problem
I m new to VB and Ive got the next problem:

On a form I have a datagrid (Datagrid1) and a ado-control (adodc1).
Now I want to get data from a database
( c:projectdbBase.mdb;= Access-dbase) in the adodc1.
This database (dbBase.mdb) just contains 1 table(tTable) and 1 field (fField).
The next step I want to know is how to get the data from the Adodc1 into the Datagrid1.
Please help me with this BIG PROBLEM and give me some helpfull code!!
Thanks.

Find Method In Adodc1
When trying to do a find record and if the record does not exist then all
my textboxs clear (data goes away) and on my adoc1 control caption I get
record -3 out of 16. On my form I have an SS1tab with four tabs.
I am new to vb, can anyone help?


Code:
Private Sub find_Click()

Dim s As String
Dim currec As Integer
s = InputBox("Enter Spaceno to look for..." & vbCr & vbCr & _
vbCr & vbCr & vbCr & "Enter find string here:", "Find SpaceNo")

Adodc1.Recordset.find ("spaceno = '" & s & "%'")
If Adodc1.Recordset.EOF Then
MsgBox "Search failed."
end sub

Adodc1 Add Record Problem
im having problem in adding records to Access database.

im using ADODC

i write this code


Code:
Private Sub Command1_Click()
Adodc1.Recordset.AddNew

Adodc1.Recordset.Update
End Sub


this error is returned


Insuffient Key coloumn information for updating or Refreshing.

i connected it to database using ADODC Properties

pls help

Problem With ADODC1 (Resolved)
I have a database program I created and it did work perfectly. However, I had a computer crash and had to format and reload everything. Now I can't use any event procedures with ADODC1.
The Error is

Compile Error
Procedure declaration does not match discription of event or procedure having the same name.

Can anyone help?

Trapping ADODC1 Error
Is there a way to trap an ADODC1 error?

I have an ON ERROR but the program still shows the ADODC1 error prior to going to the error handler routine.

Thanks.

Adodc1 Provider Not Found
When set up on a Windows 2000 Server, my program gets the error - adodc1 - provider not found, may not be properly installed...Does access need to be installed on the server? I was under the impression it did not?

Adodc1.RecordSet -- Works In NT Not In 98 (VB 6.0 && SQL 7.0)
I have form which allows the user to view and enter data.
When the value in cboCIN changes the values in txtCIN and
txtBusiness change.

To do this I have a cboCIN_Click subroutine which changes
an ado recordsource which the two text files are attached
to.

Code:
strRS = "Select Customers.CIN, Customers.Bus_Name, " & _
"Instruction1 from Customers " & _
"left join Instructions on " & _
"Instructions.CIN = Customers.CIN " & _
"Where Customers.CIN = '" & cboCIN.Text & "'"
Adodc1.RecordSource = strRS
Adodc1.Refresh

This works fine on my computer (WinNT) but does not work on
the user's machine (Win98).
The code is being processed but the values on the screen
aren't updating.

Help!

rlb_wpg

Set DataReport11.DataSource = Adodc1
Please Help.


I'm having trouble with a peice of code, the first run through it works great, but then when I run through it again (in a whie loop) it doesn't do the same as it did the first time.

When I go to

Set DataReport11.DataSource = Adodc1

the first time it jumps to

Private Sub DataReport_Initialize()

but when I loop back round it doesn't go there after.

How can I clear this so it does.

Jason

Adodc1 Add Record Problem
hi all,
the problem is Records are being added when i press the Add button. But im using RichTextBox1 because i want formatted data to be saved in the database and also i want data to Retrive data with the same Formatting when i press. First, Previous, Next And Last button.
i think i did not make any mistake this time to make you understand my problem.

Code:

Dim cnn1 As ADODB.Connection
Dim rs As ADODB.Recordset

Private Sub Command1_Click()
rs.AddNew
Call Update
rs.Update
MsgBox "Saved"
End Sub

Private Sub Command2_Click()
rs.MoveFirst
Call Display
End Sub

Private Sub Command3_Click()
rs.MovePrevious
Call Display
End Sub

Private Sub Command4_Click()
rs.MoveNext
Call Display
End Sub

Private Sub Command5_Click()
rs.MoveLast
Call Display
End Sub

Private Sub Form_Load()
Set cnn1 = New ADODB.Connection
cnn1.Provider = "Microsoft.Jet.OLEDB.4.0 "
cnn1.Open (App.Path & "db1.mdb")
Set rs = New ADODB.Recordset
rs.Open "Table1", cnn1, adOpenDynamic, adLockOptimistic, adCmdTable
rs.MoveFirst
Call Display
End Sub


Private Sub Display()
RTB.Text = rs!pop

End Sub

Private Sub Update()
rs!pop = RTB.Text
End Sub

Private Sub TLB_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "cut"
Clipboard.Clear
Clipboard.SetText (RTB.SelText)
RTB.SelText = ""
Case "copy"
Clipboard.Clear
Clipboard.SetText (RTB.SelText)
Case "paste"
RTB.SelText = Clipboard.GetText
Case "bold"
If RTB.SelBold = True Then
RTB.SelBold = False
'tlb.Buttons(5).Style=
Else
RTB.SelBold = True
End If
Case "italic"
If RTB.SelItalic = True Then
RTB.SelItalic = False
Else
RTB.SelItalic = True
End If
Case "undline"

If RTB.SelUnderline = True Then
RTB.SelUnderline = False
Else
RTB.SelUnderline = True
End If

Case "lft"

RTB.SelAlignment = rtfLeft

Case "center"

RTB.SelAlignment = rtfCenter

Case "rgt"

RTB.SelAlignment = rtfRight

Case "font"

CD.Flags = cdlCFBoth + cdlCFEffects
CD.ShowFont
RTB.SelFontName = CD.FontName
RTB.SelFontSize = CD.FontSize
RTB.SelItalic = CD.FontItalic
RTB.SelBold = CD.FontBold
RTB.SelUnderline = CD.FontUnderline
RTB.SelColor = CD.Color


Case "color"

CD.ShowColor
RTB.SelColor = CD.Color

Case "save"


'Dim rtf As String
'Dim hwnd As Long
'Form1.Text7.Text = ""
'
'rtf = Me.RTB.TextRTF
'Clipboard.Clear
'Clipboard.SetText rtf, vbCFRTF
'Text7 below is an RichTextBox
'hwnd = Form1.Text7.hwnd
'SendMessage hwnd, WM_PASTE, 0, 0
'
'Clipboard.Clear

End Select

End Sub



Im also uploading example because it will save your time.

ConnectionString
Can anyone help,
I have a vb6 program that runs against an sql 2005 DB.
It opens a connection at the start and leaves it open for the rest of the session.
However, when it comes to running stored procedures i do something different, that is to create a new command, set the command text to the stored procedure name and set the type to SP, set the active connection to my open connection, pass in the parameters.
This all works fine when i am running it on my XP development PC.
I have just received a vista laptop which i have loaded all my development gear on and i am running the application from within vb to bug it.
Now all runs fine until i get to the point of running a stored procedure and it seems to be to do with setting the active connection.
In the XP system my connection string looks like this:
Provider=MSDASQL.1;Extended Properties="DRIVER=SQL Server;SERVER=(local)SQLEXPRESS;UID=ICampbell;APP=Visual Basic;WSID=XENTEC-SMX;DATABASE=Triage;Trusted_Connection=Yes"

but in vista it just looks like this:
Provider=MSDASQL.1;

I do not know what is causing this, but if anyone has come accross something similar then could you give me a heads up.
Have i forgotten to load some sql stuff ?
Is this a vista problem ?

Thanks in advance
Ian.

What Should My Connectionstring Be For My Iis?
my existing connection string for my databse located in my documents is...

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:Documents and SettingsHomeMy DocumentsMyDB.mdb;"

what i wnt is to tranfer my database inside my trial folder located at e:inetpubwwwroot rial
i believe that iis is named localhost by default so i tried doing this but it does not work...

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\localhost rialMyDB.mdb;"


so can anyone pls tell me the proper way of doing it..... thnx

Connectionstring
hi
i need help i wanna make a connection string
if i want copy my project to another address i want have connection independ of local path( use App.path)

Connectionstring ?
Hi,

Could someone see what is wrong with my connectionstring to MS Access, it use to work, but I add the password on it then..


db.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & DbName & ";User Id=admin; password=" & DbPass & """"



Thanks!

Connectionstring
VB Code:
Dim CN As New ADODB.ConnectionCN.ConnectionString = "Driver=SQL SERVER;server=217.121.163.1;" & _"Database=PUBS;User ID=phroze;Password=mypass"CN.Open


When i use the following string, i get this error: Could not find the SQL server

I am not currently working on the system with the sqlserver on it, but from an remote pc... i entered the ip where the SQL server is on.

Is my connectionstring wrong, or is it impossible to connect to an remote SQL server?

DSN-less Connectionstring?
strConnTxt = "DSN=excel files;DBQ=" & strSourceFile & ";DefaultDir=" & App.Path & ";DriverId=790;MaxBufferSize=2048;PageTimeout=5;"

The "dsn = excel files" part of this connectionstring is giving me headaches. I want to install the prog on other computers and it might be that there are different dsn predefined or other drivers.
How do I get rid of it?

I need to access an Excel file.

I got another prob with my app too: It runs fine on my comp (even when installed i.e. outside the development env.) but it will cause a runtime 430 error on the users (NT4) comp, where it tries to access the excel file.

The setup of the connection works fine but when the recordset is queried for (perhaps rather where the parameters are created) I will get this 430 error.

Any ideas?

thx,

Helger

ADO Connectionstring
Hi

How to connect a dbase IV file with ADO.
I want to read the dbf file and put the result in datagrid.


Cheers
Ray

Connectionstring
Hi All,
I want my connectionstring to connect to any database
on the internet. How can I do it?
Than you all

Ben

ConnectionString With VB.net
Hi! There
  
          I have any problem in ConnectionString In my Application.

          In my Application on client must be connect to Multi type Database Server
             - Microsoft Sqlserver
             - Oracle
             - Mysql
         Anyway in my application client can connect to Microsoft Sql Server but It can't connect to
         Oracle and Mysql Because In Connection String. I can't use "Initial Catalog" to point my application
         connect to Database Server. In Oracle Database server someone tell me I must install "Oracle Client" in
         client but I don't agree that. How can i do in connection String Now I use Oledbconnection. It calss to connect
         my Database

Thank you for answer

ConnectionString Please Help Me!!
How can I change dataenvironment1.connection1.connectionstring property in run time?I did it like it but when I close the programme ýt returns to its defoult address,and when ý close/open connection ,its commands don t see itDataEnvironment1.Connection1.Close
DataEnvironment1.Connection1.ConnectionString = _
"Data Source=MS Access Database;Mode=ReadWrite;Initial Catalog=" & Text1.Text
Set ActiveConnection = DataEnvironment1.Connection1
DataEnvironment1.Connection1.Open

Adodc1 Data Sort Order
I am using an adodc1 object that is used via a dbcombo box to autopopulate. If I INSERT an entry into the database and use the command

Code:
adodc1.refresh
The new data is listed but the items in the DBCOMBO box are not sorted into any order. How can I force the adodc object to sort in an ascending order?

My Adodc1 Control Connection String Changes
I have an Adodc1 control connected to a certain computer on my network \HQC.

But I'm developing this program to work on other computers on another totally different network!

I have written code within my program that pulls up a textfile (database.txt) that contains the correct path to the server (SERVER). Most likely, on that other network, the pathname will be changed.

The following is included:


Code:
Open "C:Program FilesBOOKEDORDdatabase.txt" For Input As #lFile
Input #lFile, SERVER
Input #lFile, USER
Close #lFile
Adodc1.Visible = False
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SERVER & "disp-1_be.mdb;Persist Security Info=False"
Adodc1.RecordSource = "DISP"

But the above doesn't work.

Now I understand the following would be better:


Code:
Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SERVER & "disp-1_be.mdb;Persist Security Info=False"
cnn.Open
Set rst = New ADODB.Recordset
rst.Open "DISP", cnn
' I don't know what I need here...
rst.Close
Set rst = Nothing

But the difference between the two is that with the above Adodc1 connection I have 12 text boxes in arrays all tied to that connection. How do I connect my text boxes to the cnn connection.

Let's say I have a control button that adds a new record after all text boxes have been entered. Let's say my text boxes are named txtBox(0), txtBox(1), txtBox(2), etc...txtBox(12).


Code:
Private Sub Control1_Click()
Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SERVER & "disp-1_be.mdb;Persist Security Info=False"
cnn.Open
Set rst = New ADODB.Recordset
rst.Open "DISP", cnn

After the above, do I need to put in this:


Code:
rst.AddNew
rst.Fields(1) = txtBox(0)
rst.Fields(2) = txtBox(1)
rst.Fields(3) = txtBox(3)
rst.Fields(4) = txtBox(4)
rst.Close
Set rst = Nothing

Am I close to making this work? Or am I going way off the path?

Thanks,

Stephen

Data Source For Adodc1 And DataGrid1
Hi



I've got DataGrid1 (for just showing data from table in db), and data source could be diferent table from same database.

How can I set Adodc1 what database, what table to read and same thing with DataGrid1 with code?

here is code for creating table and inserting values from other table in new one. Now I want to show values from new table in DataGrid1


Code:

Dim MyConn As ADODB.Connection
Dim MyRecSet As ADODB.Recordset
Dim MyRecSet1 As ADODB.Recordset
Dim ime As String
Dim prezime As String
Dim datum As String
Dim gsm As String
Dim telefon As String

Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & rut & "';"
MyConn.Open
MyConn.Execute "CREATE TABLE zadnji_kontakt_klijent (Datum TEXT (50), Ime TEXT (50),Prezime TEXT (50), GSM TEXT (50), Telefon TEXT (50))"

Set MyRecSet1 = MyConn.Execute("SELECT * FROM klijenti order by prezime desc")

Do Until MyRecSet1.EOF

ime = "" & MyRecSet1.Fields.Item("ime").Value
prezime = "" & MyRecSet1.Fields.Item("prezime").Value
telefon = "" & MyRecSet1.Fields.Item("telefon").Value
gsm = "" & MyRecSet1.Fields.Item("gsm").Value
datum = "" & MyRecSet1.Fields.Item("dat_uklj").Value

MyConn.Execute ("INSERT INTO zadnji_kontakt_klijent (Datum, Ime, Prezime, GSM, telefon) Values ('" & datum & "', '" & ime & "', '" & prezime & "', '" & gsm & "', '" & telefon & "')")


MyRecSet1.MoveNext

Loop

MyConn.Close

ADODC1 And TDBGRID Refresh Problems
Hi,

I have an app with ADO data control linked to an Access database MDB.
I also use a TrueGrid 6 (OLE) control bound to the ADO control.

For some reason, the Grid does not populate correctly.

i.e. I have two ADODC controls and two TDBGRID controls.
Click on the one TrueGrid and select an item, then the second adodc control is passed a SQL statement relevant to the selected item in the first TrueGrid and populates the second Truegrid.

The problem is that you can click on one item, it fills the second truegrid with a further selection, click on another item in the first truegrid and nothing happens, click it again and then it populates.

Obviously I only want to click the item once and get the selection.

I think it may have something to do with how quick ADO and the access-driver refreshes the recordset because the code clears a temporary table, populates it with the selected data and I think between deleting the data and then re-populating it, the ADO data control gets ahead of itself and does not wait for the MDB to populate itself (it this makes sense).

I've tried refreshes, doevents, closing and re-binding but the effect is the same - I have to select an item twice before it refreshes the second truegrid.

Anybody else have that problem or know of a ADO trick to wait until the MDB is finished with populating?


Carl.

Transfer ADodc1 Data Between Forms!!
Dear all,
I have ADOdc1 tool in form 1 and this tool connected into database file. The input data to ADOdc1 are from text boxes in another forms like form 2.
How can i get this issue?
Looking forward to get you help
thanks.
wissam

Why Adodc1 Does Not Suppot Findfirst Method?
Hi all

I am using the code below to display records in the text boxes but does not work. massege method or data member not found .

Can any one help me to correct the findfirst method please?
Any help will be appreciated.

Private Sub DataCombo1_Click(Area As Integer)
If Area = 2 Then
If Not Adodc1.Recordset.EOF And Not Adodc1.Recordset.BOF Then
Adodc1 = DataCombo1
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.FindFirst " student_no =" & DataCombo1.BoundText
Text1 = Adodc1.Recordset.Fields("phone")
Text2 = Adodc1.Recordset.Fields("firstname")
text3 = Adodc1.Recordset.Fields("hiredate")
Text4 = Adodc1.Recordset.Fields("location")
Text5 = Adodc1.Recordset.Fields("lastname")
DataCombo1.SetFocus
Adodc1.Refresh
End If
End If
End Sub

Duplicate Primary Key Error With Adodc1
VB crashes when a duplicate primary key is sent to an access databese. I want to use a msgbox to alert the user that a duplicate record exists and return the user to the form.

Thanks in advance!!!

Code:

Private Sub Command1_Click()
Adoc1.Refresh

With Adodc1.Recordset
        .AddNew
        '!Date = Form2.TDateBox.Text
        '!Charge = Form2.inBox.Text
        !Last = Form1.Lname.Text
        '!First = Form1.Fname.Text
        '!Amount = Form4.retotal(0)
        '!Case = Form2.Stcasebox.Text
        '!Arrested = Form2.disbox.Text
        .Update
        .Requery
    End With
End Sub

Private Sub Form_Load()

With Adodc1
         
                .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
            App.Path & "ArrestLedger.mdb;Persist Security Info=False"
             
              .RecordSource = "select * from ArrestLedger order by Date"
    End With
 




Edited by - MattFenner on 6/18/2004 2:06:46 PM

Copyright 2005-08 www.BigResource.com, All rights reserved