|
-
Jul 2nd, 2007, 01:58 AM
#1
Thread Starter
Fanatic Member
[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
-
Jul 2nd, 2007, 02:06 AM
#2
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
-
Jul 2nd, 2007, 02:41 AM
#3
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
-
Jul 2nd, 2007, 04:56 AM
#4
Re: trying to connect to database
 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.
-
Jul 3rd, 2007, 12:23 PM
#5
Hyperactive Member
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.
-
Jul 4th, 2007, 11:12 AM
#6
Thread Starter
Fanatic Member
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)
-
Jul 4th, 2007, 07:08 PM
#7
Fanatic Member
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.
-
Jul 5th, 2007, 12:47 AM
#8
Thread Starter
Fanatic Member
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?
-
Jul 5th, 2007, 02:20 AM
#9
Fanatic Member
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.
-
Jul 5th, 2007, 03:40 PM
#10
Thread Starter
Fanatic Member
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?
-
Jul 5th, 2007, 06:43 PM
#11
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|