Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

Tuesday, March 20, 2012

Accessing a Microsoft Access database from within Visual C++

Hi there guys, I am currently trying to achieve a seemingly simple task in VC++ 2005. I have made a very simple form in Microsoft Access which I wish to serve as the beginnings of something greater. I created a db in MS Access named links.mdb containing on table-> Table1. Table1 contains 1 column, "Links", and i wish to read these strings into variables in my Visual C++ Windows Forms Application.

What I have done so far...

In Visual C++, I clicked on Data->Add new data source, and followed the wizard to add the microsoft access database to my application by the name, "linksDataSet". I can see the table in my left hand "Data Sources" pane in VC++. All I need to know is how to access my database from here so that I can read these strings stored in my table. Also, would be possible to schedule my application to log on to a http server and retrieve these links every time the application is executed? How would I go about doing this?

Thank you very much for your time
Regards
Linden.Umm... hi, my topic has been moved into this forum, even though I don't think it belongs here because my question is VC++ database related but can anyone help me? I would greatly appreciate it.|||44 Views and not one reply? Is this not a familiar concept?|||This is ridiculous! Why is this forum here? It obviously serves no purpose.|||

To read a Microsoft Access database table from VC++ 2005:

1. First I created a new Windows Console project in VC++.

2. Then Project | Add Class... then go under ATL and choose ATL OLEDB Consumer.

3. Click Data Source and choose Microsoft Jet 4.0 OLEDB Provider, Next>>> then type in database name.

4. Click OK, another dialog comes up, choose your table, it will create a single class for your table.

Then the code to read the data is like so:

#include "stdafx.h"

#include "Table1.h"

int _tmain(int argc, _TCHAR* argv[])

{

CoInitialize(NULL); // Be sure to initialize COM somewhere in your app one time...

CTable1 table1;

HRESULT hr = table1.OpenAll();

for(;;)

{

hr = table1.MoveNext();

if (S_OK != hr) break;

printf("table1.f1=%lu\n", table1.m_f1);

printf("table1.f2=%S\n", table1.m_f2);

}

return 0;

}

|||I am currently working in a windows forms application, how would the code change?

Access/SQL "Write Conflict"

Hello,
I'm using a Access 97 Front-end and a SQL Server 2000 back-end.
When entering a subform on a form, information has to be saved to the
database.
But when entering the subform I get a "Write conflict" error in Access.
In SQL I'm using 3 tables with 1 view defined on those 3 tables. I use
INSTEAD OF INSERT/UPDATE/DELETE triggers to handle
INSERTS/UPDATES/DELETES.
In Access I use that View as a Source for the form.
Does anyone know why I get this error?
Roy
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!
When I followed the execution of the code, I saw that the "Write
Conflict" error appeared after the following sub executed:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then If ap_ConfirmAction(Me, apUpdate) = vbNo Then
DoCmd.RunCommand acCmdUndo
'###ROY TOEGEVOEGD VOOR GENEREREN GUID
If IsNull(Me.dummyveld) Then
Set ObjGUID = CreateObject("event.util")
GUID = ObjGUID.GetNewGUID()
Me.dummyveld = Mid(GUID, 2, 36)
Set ObjGUID = Nothing
End If
End Sub
After the "End Sub" the "Write Conflict" error pops up.
I hope someone can help me.
Roy
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!

Access/SQL "Write Conflict"

Hello,
I'm using a Access 97 Front-end and a SQL Server 2000 back-end.
When entering a subform on a form, information has to be saved to the
database.
But when entering the subform I get a "Write conflict" error in Access.
In SQL I'm using 3 tables with 1 view defined on those 3 tables. I use
INSTEAD OF INSERT/UPDATE/DELETE triggers to handle
INSERTS/UPDATES/DELETES.
In Access I use that View as a Source for the form.
Does anyone know why I get this error?
Roy
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!When I followed the execution of the code, I saw that the "Write
Conflict" error appeared after the following sub executed:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then If ap_ConfirmAction(Me, apUpdate) = vbNo Then
DoCmd.RunCommand acCmdUndo
'###ROY TOEGEVOEGD VOOR GENEREREN GUID
If IsNull(Me.dummyveld) Then
Set ObjGUID = CreateObject("event.util")
GUID = ObjGUID.GetNewGUID()
Me.dummyveld = Mid(GUID, 2, 36)
Set ObjGUID = Nothing
End If
End Sub
After the "End Sub" the "Write Conflict" error pops up.
I hope someone can help me.
Roy
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!

Access Yes/No field equivalent in Sql Server

Hi,
I am building a table in sql server. One of the field is equivalent to
Access yes/no field. This will have values Yes or No obtained from a form in
Asp page. I am wonering what would be the correct datatype for this field.
Thanks.char(1) - "y" or "n"
varchar(3) - "yes" or "no"
"Jack" <Jack@.discussions.microsoft.com> wrote in message
news:EAF7A165-2386-442D-881C-775B3C161473@.microsoft.com...
> Hi,
> I am building a table in sql server. One of the field is equivalent to
> Access yes/no field. This will have values Yes or No obtained from a form
> in
> Asp page. I am wonering what would be the correct datatype for this field.
> Thanks.|||Jack,
You could use a bit datatype with support for 0 or 1 then translate that to
Yes or No in code. You could also use a char(3) with a check contraint
limiting the valid entries to Yes/No. A default constratint can be added as
well for a default of Yes or No when a user does not explicitly enter a
value.
HTH
Jerry
"Jack" <Jack@.discussions.microsoft.com> wrote in message
news:EAF7A165-2386-442D-881C-775B3C161473@.microsoft.com...
> Hi,
> I am building a table in sql server. One of the field is equivalent to
> Access yes/no field. This will have values Yes or No obtained from a form
> in
> Asp page. I am wonering what would be the correct datatype for this field.
> Thanks.|||You may consider using Bit for boolean data type in Presentation layer.
Perayu
"Jack" <Jack@.discussions.microsoft.com> wrote in message
news:EAF7A165-2386-442D-881C-775B3C161473@.microsoft.com...
> Hi,
> I am building a table in sql server. One of the field is equivalent to
> Access yes/no field. This will have values Yes or No obtained from a form
> in
> Asp page. I am wonering what would be the correct datatype for this field.
> Thanks.|||Thanks for all the help from Raymond, Jerry and Perayu. I appreciate it.
"Perayu" wrote:

> You may consider using Bit for boolean data type in Presentation layer.
> Perayu
> "Jack" <Jack@.discussions.microsoft.com> wrote in message
> news:EAF7A165-2386-442D-881C-775B3C161473@.microsoft.com...
>
>

Saturday, February 25, 2012

access Sql from asp.net

hi,

i have few forms in my form.i dont want to repeat coding for database connectivity.i want to make it as standard in one file.so that in future if any changes in database i can access that file and modify it.

im using global.aspx file here

Sub Session_Start(ByVal senderAsObject,ByVal eAs EventArgs)

' Fires when the session is started

Session("ConnectionPath") ="DRIVER={SQL server};SERVER=localhost;UID=sa;PWD=;DATABASE=mas;"

EndSub

now in my forms how can i access this connection path without repeatin the above code again in my dim con = new sql(...) i dont want to do like this..

You need to use the web.config...

add this

<?xmlversion="1.0"?>
<configurationxmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<addname="ConnectionString"connectionString="Data Source=<SERVERNAME>;Initial Catalog=<DATABASENAME>;UID=<USERNAME>;Password=<PASSWORD>;"providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
......
</system.web>
</configuration>

Then in you code behind do this to access is...

Dim conn as SqlConnection =New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)


|||

Or better you create a public shared method and create it there.

|||

Error 101 Value of type 'System.Configuration.ConnectionStringSettingsCollection' cannot be converted to 'String'.

im getting this error

|||

Since you have added the connection string in session variable, use the below code to access it Dim conn as SqlConnection = New SqlConnection(session("ConnectionPath"))

|||

hi, thankyou,i manged to solve it with all ur advices...

i have a doubt in procedure.is it possible to retive value of a column from a table inside procedure?someth like this

cREATE PROCEDURE a @.val varchar(50)
AS
declare @.type char(2)
set @.type='select id from dbo.Handle_Master where name = @.val'
if @.type='A'
Begin .....

if @.Type='B'

Begin...

someth like this...is that possible??if can!! how ?i tried like this but no error and no result also...

|||

wat i felt here is instead of accesing from table ,i planned to pass the value as parameter...jus changed the logic...its workin fine...

Friday, February 24, 2012

Access Pass through Query Executes Multiple Times

Hi,
I am using MSACCESS 2002 with SQL Server 2000. I have an unbound form when it opens I assign a pass through query to the rowsource of a combo box. The pass through query calls a stored procedure. On my form unload event I set the rowsource to empty.
When I load the form I am only assigning the query once, however, it is appearing in profiler as many as three times within milliseconds of each other.
Can someone tell me if the query is actually executing three times or is this some anomoly of profiler that is causing it to appear this way. I have included the results of the trace below.
Thanks
1.
EVENT CLASS TEXT DATA APPLICATION nAME LOGIN NAME
------
SQL:BatchCompletedexec setEECboRS '4/23/2004','4/29/2004'Microsoft Office XPScheduler15
READS WRITES CPU DURATION CLIENT PROCESS ID START TIME
-----
6330165712572004-04-24 23:45:05.953
2.
EVENT CLASS TEXT DATA APPLICATION nAME LOGIN NAME
------
SQL:BatchCompletedexec setEECboRS '4/23/2004','4/29/2004'Microsoft Office XPScheduler16
READS WRITES CPU DURATION CLIENT PROCESS ID START TIME
-----
6330135712572004-04-24 23:45:05.970
3.
EVENT CLASS TEXT DATA APPLICATION nAME LOGIN NAME
------
SQL:BatchCompletedexec setEECboRS '4/23/2004','4/29/2004'Microsoft Office XPScheduler16
READS WRITES CPU DURATION CLIENT PROCESS ID START TIME
-----
6330165712572004-04-24 23:45:05.983
Since you're using an unbound form, step through your code and then
look at the Profiler trace after each step. It's possible that this is
caused because you don't have SET NOCOUNT ON as the first line in your
stored procedure.
--Mary
On Sun, 25 Apr 2004 06:06:02 -0700, "Lance"
<anonymous@.discussions.microsoft.com> wrote:

>Hi,
>I am using MSACCESS 2002 with SQL Server 2000. I have an unbound form when it opens I assign a pass through query to the rowsource of a combo box. The pass through query calls a stored procedure. On my form unload event I set the rowsource to empty.
When I load the form I am only assigning the query once, however, it is appearing in profiler as many as three times within milliseconds of each other.
>Can someone tell me if the query is actually executing three times or is this some anomoly of profiler that is causing it to appear this way. I have included the results of the trace below.
>Thanks
>1.
> EVENT CLASS TEXT DATA APPLICATION nAME LOGIN NAME
>------
>SQL:BatchCompletedexec setEECboRS '4/23/2004','4/29/2004'Microsoft Office XPScheduler15
> READS WRITES CPU DURATION CLIENT PROCESS ID START TIME
>-----
>6330165712572004-04-24 23:45:05.953
>2.
> EVENT CLASS TEXT DATA APPLICATION nAME LOGIN NAME
>------
>SQL:BatchCompletedexec setEECboRS '4/23/2004','4/29/2004'Microsoft Office XPScheduler16
> READS WRITES CPU DURATION CLIENT PROCESS ID START TIME
>-----
>6330135712572004-04-24 23:45:05.970
>3.
> EVENT CLASS TEXT DATA APPLICATION nAME LOGIN NAME
>------
>SQL:BatchCompletedexec setEECboRS '4/23/2004','4/29/2004'Microsoft Office XPScheduler16
> READS WRITES CPU DURATION CLIENT PROCESS ID START TIME
>-----
>6330165712572004-04-24 23:45:05.983
|||Mary,
I did not have set nocount on but adding it did not affect the results in profiler. The profiler results I posted all have the same processID but one has a CPU value of 13 while the other two lines have a CPU value of 16. The computer I am using has an
intel pentium 4 hyperthreading cpu that appears as two CPU to my operating system. This may be what is causing the results to appear multiple times even though the stored procedure is only executed once. Can you confirm by looking at the output I posted
?
Thanks,
Lance
|||That I couldn't tell you -- can you test from a different machine?
--mary
On Wed, 28 Apr 2004 10:10:58 -0700, "Lance"
<anonymous@.discussions.microsoft.com> wrote:

>I did not have set nocount on but adding it did not affect the results in profiler. The profiler results I posted all have the same processID but one has a CPU value of 13 while the other two lines have a CPU value of 16. The computer I am using has an
intel pentium 4 hyperthreading cpu that appears as two CPU to my operating system. This may be what is causing the results to appear multiple times even though the stored procedure is only executed once. Can you confirm by looking at the output I poste
d?
|||Mary,
I can not move it to another machine at this time but will eventually (well, I could but don't want to for this as I don't have the time and it can wait). By the way, I do have a book that you co-wrote and found it a very good reference.
Lance
|||My form calls a pass-through query in my Access 2000/SQL Server App, and it actually executes the stored procedure 3 times. This is very annoying.
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
|||My form calls a pass-through query in my Access 2000/SQL Server App, and it actually executes the stored procedure 3 times. This is very annoying.
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
|||Open a Profiler trace and step through your form code that calls the
stored procedure to pinpoint why it's getting called 3 times.
--Mary
On Tue, 29 Jun 2004 13:33:46 -0700, SqlJunkies User
<User@.-NOSPAM-SqlJunkies.com> wrote:

>My form calls a pass-through query in my Access 2000/SQL Server App, and it actually executes the stored procedure 3 times. This is very annoying.
>--
>Posted using Wimdows.net NntpNews Component -
>Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.

Sunday, February 19, 2012

Access Pass through Query Executes Multiple Times

Hi,
I am using MSACCESS 2002 with SQL Server 2000. I have an unbound form when
it opens I assign a pass through query to the rowsource of a combo box. Th
e pass through query calls a stored procedure. On my form unload event I se
t the rowsource to empty.
When I load the form I am only assigning the query once, however, it is appe
aring in profiler as many as three times within milliseconds of each other.
Can someone tell me if the query is actually executing three times or is thi
s some anomoly of profiler that is causing it to appear this way. I have in
cluded the results of the trace below.
Thanks
1.
EVENT CLASS TEXT DATA
APPLICATION nAME LOGIN NAME
----
----
SQL:BatchCompleted exec setEECboRS '4/23/2004','4/29/2004' Microsoft Office
XP Scheduler 15
READS WRITES CPU DURATION CLIENT PROCESS ID START TIME
----
--
633 0 16 5712 57 2004-04-24 23:45:05.953
2.
EVENT CLASS TEXT DATA
APPLICATION nAME LOGIN NAME
----
----
SQL:BatchCompleted exec setEECboRS '4/23/2004','4/29/2004' Microsoft Office
XP Scheduler 16
READS WRITES CPU DURATION CLIENT PROCESS ID START TIME
----
--
633 0 13 5712 57 2004-04-24 23:45:05.970
3.
EVENT CLASS TEXT DATA
APPLICATION nAME LOGIN NAME
----
----
SQL:BatchCompleted exec setEECboRS '4/23/2004','4/29/2004' Microsoft Office
XP Scheduler 16
READS WRITES CPU DURATION CLIENT PROCESS ID START TIME
----
--
633 0 16 5712 57 2004-04-24 23:45:05.983Since you're using an unbound form, step through your code and then
look at the Profiler trace after each step. It's possible that this is
caused because you don't have SET NOCOUNT ON as the first line in your
stored procedure.
--Mary
On Sun, 25 Apr 2004 06:06:02 -0700, "Lance"
<anonymous@.discussions.microsoft.com> wrote:

>Hi,
>I am using MSACCESS 2002 with SQL Server 2000. I have an unbound form when it open
s I assign a pass through query to the rowsource of a combo box. The pass through
query calls a stored procedure. On my form unload event I set the rowsource to empt
y.
When I load the form I am only assigning the query once, however, it is appearing in profile
r as many as three times within milliseconds of each other.
>Can someone tell me if the query is actually executing three times or is th
is some anomoly of profiler that is causing it to appear this way. I have i
ncluded the results of the trace below.
>Thanks
>1.
> EVENT CLASS TEXT DATA
APPLICATION nAME LOGIN NAME
>----
---
>SQL:BatchCompleted exec setEECboRS '4/23/2004','4/29/2004' Microsoft Office
XP Scheduler 15
> READS WRITES CPU DURATION CLIENT PROCESS ID STAR
T TIME
>----
--
> 633 0 16 5712 57 2004-04-24 23:45:05.953
>2.
> EVENT CLASS TEXT DATA
APPLICATION nAME LOGIN NAME
>----
---
>SQL:BatchCompleted exec setEECboRS '4/23/2004','4/29/2004' Microsoft Office
XP Scheduler 16
> READS WRITES CPU DURATION CLIENT PROCESS ID STAR
T TIME
>----
--
> 633 0 13 5712 57 2004-04-24 23:45:05.970
>3.
> EVENT CLASS TEXT DATA
APPLICATION nAME LOGIN NAME
>----
---
>SQL:BatchCompleted exec setEECboRS '4/23/2004','4/29/2004' Microsoft Office
XP Scheduler 16
> READS WRITES CPU DURATION CLIENT PROCESS ID STAR
T TIME
>----
--
> 633 0 16 5712 57 2004-04-24 23:45:05.983|||Mary,
I did not have set nocount on but adding it did not affect the results in pr
ofiler. The profiler results I posted all have the same processID but one h
as a CPU value of 13 while the other two lines have a CPU value of 16. The
computer I am using has an
intel pentium 4 hyperthreading cpu that appears as two CPU to my operating s
ystem. This may be what is causing the results to appear multiple times eve
n though the stored procedure is only executed once. Can you confirm by loo
king at the output I posted
?
Thanks,
Lance|||That I couldn't tell you -- can you test from a different machine?
--mary
On Wed, 28 Apr 2004 10:10:58 -0700, "Lance"
<anonymous@.discussions.microsoft.com> wrote:

>I did not have set nocount on but adding it did not affect the results in profiler.
The profiler results I posted all have the same processID but one has a CPU value
of 13 while the other two lines have a CPU value of 16. The computer I am using has
an
intel pentium 4 hyperthreading cpu that appears as two CPU to my operating s
ystem. This may be what is causing the results to appear multiple times eve
n though the stored procedure is only executed once. Can you confirm by loo
king at the output I poste
d?|||Mary,
I can not move it to another machine at this time but will eventually (well,
I could but don't want to for this as I don't have the time and it can wait
). By the way, I do have a book that you co-wrote and found it a very good
reference.
Lance|||My form calls a pass-through query in my Access 2000/SQL Server App, and it
actually executes the stored procedure 3 times. This is very annoying.
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine sup
ports Post Alerts, Ratings, and Searching.|||Open a Profiler trace and step through your form code that calls the
stored procedure to pinpoint why it's getting called 3 times.
--Mary
On Tue, 29 Jun 2004 13:33:46 -0700, SqlJunkies User
<User@.-NOSPAM-SqlJunkies.com> wrote:

>My form calls a pass-through query in my Access 2000/SQL Server App, and it
actually executes the stored procedure 3 times. This is very annoying.
>--
>Posted using Wimdows.net NntpNews Component -
>Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports P
ost Alerts, Ratings, and Searching.

Saturday, February 11, 2012

Access Form/Combo Box not liking sql syntax: Need sql server syntax

This query is supposed to call a form 'f_test' combo box 'combo2'. However,
I have found that the syntax is used for access sql and not sql server 2000.
(The combo box holds a value that will return in f_test subform a resultset
according to what is selected in the combo box, f_view1 is a query view
created that is returns to the subform records according to Area column).
Please hellp me get the syntax right. If you have any suggestions on books
for reference that would be wonderful. Thanks, Mitchell
PARAMETERS [Forms]![f_test]![Combo2] Text ( 255 );
SELECT f_view1.Area
FROM f_view1
WHERE (f_view1.Area Like [Forms]![f_test]![Combo2])
Hi Mitchell
"Mitchell_Collen" wrote:

> This query is supposed to call a form 'f_test' combo box 'combo2'. However,
> I have found that the syntax is used for access sql and not sql server 2000.
> (The combo box holds a value that will return in f_test subform a resultset
> according to what is selected in the combo box, f_view1 is a query view
> created that is returns to the subform records according to Area column).
> Please hellp me get the syntax right. If you have any suggestions on books
> for reference that would be wonderful. Thanks, Mitchell
> PARAMETERS [Forms]![f_test]![Combo2] Text ( 255 );
> SELECT f_view1.Area
> FROM f_view1
> WHERE (f_view1.Area Like [Forms]![f_test]![Combo2])
>
The access newsgroup may be a better place to get an answer to this!
John
|||John Bell wrote:
>Hi Mitchell
>[quoted text clipped - 8 lines]
>The access newsgroup may be a better place to get an answer to this!
>John
I will try them. Thanks.
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums.aspx/sql-server/200704/1

Access Form/Combo Box not liking sql syntax: Need sql server syntax

This query is supposed to call a form 'f_test' combo box 'combo2'. However,
I have found that the syntax is used for access sql and not sql server 2000.
(The combo box holds a value that will return in f_test subform a resultset
according to what is selected in the combo box, f_view1 is a query view
created that is returns to the subform records according to Area column).
Please hellp me get the syntax right. If you have any suggestions on books
for reference that would be wonderful. Thanks, Mitchell
PARAMETERS [Forms]![f_test]![Combo2] Text ( 255 );
SELECT f_view1.Area
FROM f_view1
WHERE (f_view1.Area Like [Forms]![f_test]![Combo2])Hi Mitchell
"Mitchell_Collen" wrote:
> This query is supposed to call a form 'f_test' combo box 'combo2'. However,
> I have found that the syntax is used for access sql and not sql server 2000.
> (The combo box holds a value that will return in f_test subform a resultset
> according to what is selected in the combo box, f_view1 is a query view
> created that is returns to the subform records according to Area column).
> Please hellp me get the syntax right. If you have any suggestions on books
> for reference that would be wonderful. Thanks, Mitchell
> PARAMETERS [Forms]![f_test]![Combo2] Text ( 255 );
> SELECT f_view1.Area
> FROM f_view1
> WHERE (f_view1.Area Like [Forms]![f_test]![Combo2])
>
The access newsgroup may be a better place to get an answer to this!
John|||John Bell wrote:
>Hi Mitchell
>> This query is supposed to call a form 'f_test' combo box 'combo2'. However,
>> I have found that the syntax is used for access sql and not sql server 2000.
>[quoted text clipped - 8 lines]
>> FROM f_view1
>> WHERE (f_view1.Area Like [Forms]![f_test]![Combo2])
>The access newsgroup may be a better place to get an answer to this!
>John
I will try them. Thanks.
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200704/1