Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC Connection String Issue's 1

Status
Not open for further replies.

chuckh70

Programmer
Feb 4, 2004
71
US
Hello,

I have been working on several web based reports for a little while now, and just about ready to turn them in when I noticed all of the records display 8hrs ahead. After talking with Tech Support I was informed I can't connect to SQl Server. I must use the ODBC and connect through there server to get the data, and have it display properly.

After some messing around I managed to figure out the connection string, but I am not sure how to change my function to use it or if I can. Or is there a way to cheat and have it subtract 8 hours?

here is the ODBC string I need to use, and my function.

Thanks again for the help.

Code:
ARAuthentication=;DSN=AR System ODBC Data Source;UID=CH202806;ARServer=bkapp04;PWD=pword;SERVER=NotTheServer

Code:
Function  SetData()
	
Dim  connString As String = "server=bkwbreporting01;uid=sa;pwd=sa;database=ARSystem"  
    Dim conn As SqlConnection  = new SqlConnection(connString)
    
    Dim selectQuery As string = "Select assigned_to_group_, COUNT(*) AS tcktOpen FROM HPD_HelpDesk WHERE status >= 4 and DATEADD(dd, Create_Time / 86400, '1/1/1970') >= '" & nmStart & "' GROUP BY assigned_to_group_ Order By assigned_to_group_"
    'Dim selectQuery As string = "SELECT DATEADD(dd, Create_Time / 86400, '1/1/1970') AS 'Date Open', COUNT(*) AS tcktOpen FROM HPD_HelpDesk WHERE (Assigned_To_Group_ = '" & MySelect.Value & "') and (Status <=4) GROUP BY DATEADD(dd, Create_Time / 86400, '1/1/1970') Order By DATEADD(dd, Create_Time / 86400, '1/1/1970')ASC"
    'Dim selectQuery As string = "SELECT DATEADD(dd, Create_Time / 86400, '1/1/1970') AS 'Date Open', COUNT(*) AS tcktOpen FROM HPD_HelpDesk WHERE (Assigned_To_Group_ = '" & MySelect.Value & "') AND (Status <=4) GROUP BY DATEADD(dd, Create_Time / 86400, '1/1/1970') Order By DATEADD(dd, Create_Time / 86400, '1/1/1970')ASC"
    Dim myCommand As SqlCommand  = new SqlCommand(selectQuery, conn)
   	
   	conn.Open()
   	
   	Dim myReader As SqlDataReader = myCommand.ExecuteReader()
   	
 	'set dataReader to data property
   	Chart.Series.Data = myReader
   	
   	'Cleanup
 	myReader.Close()
   	conn.Close()
	

End Function
 
You already have the basics of what you could do in your SQL query.

Couldn't you just wrap another DATEADD around each of you date fields but rather than adding days add hours and set the value to -8.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
So I could just wrap it around my current date add?

Something like

Code:
DATEADD(hh,DATEADD(dd, Create_Time / 86400, '1/1/1970')-8)
 
I haven't got SQL Server here to test it but yes that looks fine.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
tells me it requires 3 arguments?

Thanks for the help by the way.
 
Yes it does (sorry missed that in your above code).

You have to include all 3 as you have done in your previous DateAdd. e.g.

Code:
DATEADD(hh, -8, DATEADD(dd, Create_Time / 86400, '1/1/1970'))

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
ok this works thank you, but I noticed another slight problem. my dateadd strips it down to just the date so the new date add just takes it from midnight and makes it 4 p.m.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top