Results 1 to 11 of 11

Thread: [RESOLVED] trying to connect to database

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Resolved [RESOLVED] trying to connect to database

    Hi all

    Im working on connecting to a database over our network

    I dont know to much about the database so im wondering what questions i need answered by the db admin in order to connect to it?


    thanks

    Crash

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: trying to connect to database

    What kind of database are you using?

    Did you take a look at System.Data namespace?
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: trying to connect to database

    You must know if your DB supports TCP/IP communication or pipeline communication.

    Your DB must also be running on a NetWorkService account or any account that can communicate through the network
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  4. #4
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: trying to connect to database

    Quote Originally Posted by Crash893
    Hi all

    Im working on connecting to a database over our network

    I dont know to much about the database so im wondering what questions i need answered by the db admin in order to connect to it?


    thanks

    Crash
    Ask what kind of database you are using then go to http://connectionstrings.com/ for the appropriate connection strings.

  5. #5
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: trying to connect to database

    Connecting to a database is very simple. First what kind of database (oracle, access etc) and second which method. There's the odbc connection and then the oledbconnection. Its not difficult at all. Need some more information - Jennifer.

  6. #6

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: trying to connect to database

    does it make sense (or is it possible)

    to use sqldatareader to fill a dataset


    the information I'm working with is pretty small 19 feilds and about 3000 records ( it will grow obviously but it took a year to get to 3000)

  7. #7
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: trying to connect to database

    No and Yes. DataAdapter has a fine implementation for filling the DataSet. And of course it's possible. It's like
    Code:
    DataTable t = new DataTable();
    			IDataReader reader = FromSomeConnection();
    			for (int i = 0; i < reader.FieldCount; i++) {
    				DataColumn c = new DataColumn();
    				// Do something with the column
    				t.Columns.Add(c);
    			}
    			while (reader.Read()) {
    				DataRow r = t.NewRow();
    				for (int i = 0; i < reader.FieldCount; i++) {
    					r[i] = reader[i];
    				}
    				t.Rows.Add(r);
    			}
    When working with reader, it's more readable if you have a strongly type objects like
    Code:
    List<Employee> e = new List<Employee>();
    			IDataReader reader = FromSomeConnection();
    			while (reader.Read()) {
    				e.Add(new Employee(reader["last_name"].ToString(), reader["first_name"].ToString(), reader["middle_name"].ToString()));
    			}
    			
    			// Do something with the list of employees.
    This way we know what type of list we are manipulating.

  8. #8

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: trying to connect to database

    i am reading a list of record

    ticket type to get a count (hangs = 2 dissconnects = 4.....)
    and
    ticket date to get a count ( monday =10 tuesday =3.....)


    what im trying to do is read the database really quick to get all the data i could possibly need

    then use date time selecters inside my gui to narrow down the reports that i give.


    is there a better way to do this than to run the reader through a loop to deposit the info into a dataset?

  9. #9
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: trying to connect to database

    I'm not sure what is it you are doing but can't "select count" or something like that achieve your counting stuff? I might be wrong here so my apologies. Also coordinate with your DB admin if it's with SQL; they know best.

    Maybe something like this?

    select count(ticket_type), ticket_type from tickets
    group by ticket_type

    Again, I'm not really sure here if this is what you are looking, sorry in advance.

  10. #10

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: trying to connect to database

    to tell you the truth im makeing this up as i go

    do you think it would be better to send 1 query per item

    or send one larger query and then calculate from some sort of container i stick it in?

  11. #11
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: trying to connect to database

    It always depends on what's best for your situation. If SQL can't manage to calculate the things you want, go with the containers and calculate it there. SQL btw is best on doing these kind of things, it is designed to do this kind of jobs. So, if given a chance to do it in SQL, go for SQL.

    Just a short advice, just create the program that do its job; optimization later.

    I think you are confusing things that you want to do. Just do a code for your app and if tests show it needs improvement, improve it. I can't really help you on participating on your project. We are not team members but we can help you on some little things. If you need few things worth discussing, I'm (we are) just PMed away. But I can't promise anything, I'm no expert.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width