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
Printable View
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
What kind of database are you using?
Did you take a look at System.Data namespace?
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
Ask what kind of database you are using then go to http://connectionstrings.com/ for the appropriate connection strings.Quote:
Originally Posted by Crash893
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.
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)
No and Yes. DataAdapter has a fine implementation for filling the DataSet. And of course it's possible. It's like
When working with reader, it's more readable if you have a strongly type objects likeCode: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);
}
This way we know what type of list we are manipulating.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.
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?
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.
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?
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. :)