473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

database on a Web server

17
Hi huys,

I need to write an application (vb.net or c# NOT asp pages) that retrieve data from a database (ms access) which resides on our webserver and display it to the client user.

I'm not sure how to access the database from the client's machine, meaning
the databse is not on the network but rather on a webserver. How do i connect to retrieve info from a file or d.b. in that case.

please point me or help me draft a solution to this type of scenarion, that would be great.

let me know if more info is needed.

TIA

p.s. I can't use asp pages for that matter.
May 27 '08 #1
9 1313
Plater
7,872 Expert 4TB
That's kind of a weird situation.
You have a webserver with a ms access database, but you can't write software to run on that webserver (be it a web application or stand alone application)

Are you expecting your users to have to download the entire database every time they want to use it?
How are you planning on having it rectify changes with the server?
May 27 '08 #2
vstud
17
No, i don't want the user to download the databse, they don't need to change any data on the database, just to view info from the different tables (different views).

I should be able to write a stand alone application ond place it on the weserver,
but wasn't sure that its something acceptable to do..
how do the user trigger the executable?
should he use something like www.myurl.com/myexe.com ?

or should the application reside on the user machine and with some ADO commands or alike access the databse (if it's possible somehow and I'm missing it let me know).

TIA
May 27 '08 #3
Plater
7,872 Expert 4TB
And you aren't allowed to add things to the webserver located on that computer?
Hmm.
I guess you could write a custom executable that resides/runs on that system. It would have to listen on a socket for connections from whatever software you create to run on their client systems.
You really got stuck with nasty restrictions, this would be an easy task if you were allowed to make changes to the webserver modules on the computer that is hosting the access database.
May 27 '08 #4
vstud
17
sorry, I should be clearer,
Yes,I'm allowed to add and change things on the webserver, and I already
implemented some asp pages. I'm just checking my options as I was thinking that I can accomplish the same thing via vb.net and control the security part of the application better ..correct me if I'm wrong..

Is there a way that i can use, web services and refer to the web service via
stand alone application on the user machine?
May 28 '08 #5
Curtis Rutland
3,256 Expert 2GB
Is there a way that i can use, web services and refer to the web service via
stand alone application on the user machine?
I've had an issue like this once. What I did is create a .asmx web service on the web server. I added several methods, all taking a string for a parameter (the sql statement).

One method was for selecting (returns a DataTable), one was for selecting scalar like count and sum (returning int) and the other was for all other queries (returning int for rows affected). It's like a passthrough engine, using the same methods you would use if you could do it locally, but since you can't, put it on the web server.

Then you write your console/windows app, and add a web reference to the service you created.

I can post sample code, if you need it.
May 28 '08 #6
vstud
17
I've had an issue like this once. What I did is create a .asmx web service on the web server. I added several methods, all taking a string for a parameter (the sql statement).

..... <snip>
I can post sample code, if you need it.
please do post or send me sample code, my experience with web services is thin

TIA
May 28 '08 #7
Curtis Rutland
3,256 Expert 2GB
please do post or send me sample code, my experience with web services is thin

TIA
Sorry it's taken me so long to reply; the computer I have my code on was bluescreening this morning.

Ok, first create a web service project:




Then, in Service.cs this is the code I used. You will need to modify it to fit your needs:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Web;
  3. using System.Web.Services;
  4. using System.Web.Services.Protocols;
  5. using System.Data;
  6. using System.Data.OleDb;
  7.  
  8. [WebService(Namespace = "http://tempuri.org/")]
  9. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  10. public class Service : System.Web.Services.WebService
  11. {
  12.     private const string CONN_STR = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\db.mdb;User Id=admin;Password=;";
  13.     private OleDbConnection Conn;
  14.     private OleDbCommand Cmd;
  15.     public Service()
  16.     {
  17.         Conn = new OleDbConnection(CONN_STR);
  18.         Cmd = new OleDbCommand();
  19.         Cmd.Connection = Conn;
  20.         //Uncomment the following line if using designed components 
  21.         //InitializeComponent(); 
  22.     }
  23.  
  24.     [WebMethod]
  25.     public DataTable Select(string selectCommandText)
  26.     {
  27.         OleDbDataAdapter adapt = new OleDbDataAdapter(selectCommandText,Conn);
  28.         DataSet ds = new DataSet();
  29.         adapt.Fill(ds, "table");
  30.         return ds.Tables["table"];
  31.     }
  32.  
  33.     [WebMethod]
  34.     public int ExecuteNonQuery(string commandText)
  35.     {
  36.         //Cmd.CommandText = commandText;
  37.         Cmd = new OleDbCommand(commandText, Conn);
  38.         Cmd.Connection.Open();
  39.         int affectedRows = Cmd.ExecuteNonQuery();
  40.         Cmd.Connection.Close();
  41.         return affectedRows;
  42.     }
  43.  
  44.     [WebMethod]
  45.     public double ExecuteScalar(string selectScalarCommandText)
  46.     {
  47.         Cmd.CommandText = selectScalarCommandText;
  48.         Cmd.Connection.Open();
  49.         double result = Convert.ToDouble(Cmd.ExecuteScalar());
  50.         Cmd.Connection.Close();
  51.         return result;
  52.     }
  53. }
  54.  
Then in another project, you can add a web reference, using the url to the service. For example, if your website was www.somesite.com, and you put it in a directory called "service," the url you would link to is http://www.somesite.com/service/service.asmx . Then, instantiate the webservice object:
Expand|Select|Wrap|Line Numbers
  1. string tmp = "insert into test (fname, lname) values ('jim','bob')";
  2. testWebServicce.localhost.Service serve = new testWebServicce.localhost.Service();
  3. serve.ExecuteNonQuery(tmp);
  4.  
You will need to replace testWebServicce.localhost with whatever namespace you are using.

Also make sure that the user: IUSR_<yourmachinename>
(Replace <yourmachinename> with the computer name, in this case, the webserver)
has access to the database directory,

This could be a little hard to follow if you don't have any experience. If you have trouble with any part, just reply and let me know.
May 28 '08 #8
vstud
17
<snip>
This could be a little hard to follow if you don't have any experience. If you have trouble with any part, just reply and let me know.
This is great, thank you for your effort. I have better grasp now, still it will take me some time to delve into it.
One quick question: I take it that once the web service is in place, one is able to create the reference to it from vb.net (or c#) and then drop a grid view (for example) on his form and trigger and bind the web service methods ..correct?

Thank you
May 29 '08 #9
Curtis Rutland
3,256 Expert 2GB
Yes, you can add this reference from either VB or C#. You can't directly bind to one of the methods, but you can do it indirectly.

Expand|Select|Wrap|Line Numbers
  1. namespace.youUsed.Service s = new namespace.youUsed.Service();
  2. DataTable table = s.Select("select * from table");
  3. GridView1.DataSource = table;
  4. GridView1.DataBind();
  5.  
This is great, thank you for your effort. I have better grasp now, still it will take me some time to delve into it.
One quick question: I take it that once the web service is in place, one is able to create the reference to it from vb.net (or c#) and then drop a grid view (for example) on his form and trigger and bind the web service methods ..correct?

Thank you
May 29 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: xixi | last post by:
hi, we use db2 udb v8.1 on windows, i am trying to use federated database objects to create wrapper, even though i have update dbm cfg using federated yes, i still get error "the instance for the...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
0
by: Jonathan Wood | last post by:
I seem to be having errors creating and accessing an SQL database. Unfortunatley, I am brand new to SQL setup and administration issues so this really is not my area of expertise. I know I had...
2
by: Patrick F | last post by:
Hi, i have SQL Server 2005 and a database set that is called, myCompany the problem is that i cant connect from my page to it, here is from the web.config: ( i have got this connectionstring from...
2
by: Tor Inge Rislaa | last post by:
Database on remote server On the remote server where my ASP.NET application is located there is no SQL Server or SQL Server Express. When I test my application locally it works fine because...
9
by: TC | last post by:
Like a lot of database developers, I often choose Jet for the back- end. I'm starting to worry about what will happen when Jet is deprecated. Ostensibly, Jet users like me must switch to SQL Server...
21
by: nihad.nasim | last post by:
Hi there, I have a database in Access that I need on the web. The web page should connect to the database and write records for certain tables and view records for others. I want to know a...
2
by: Justin | last post by:
I have 2 sql server 2000 database that participate in log shipping. Server A is the source database, which log ships to a database on Server B. The database on Server B is in a warm stand by/read...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.