Jump to content
Xtreme .Net Talk

rbb

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by rbb

  1. Now that makes sense. Thanks! Rob
  2. I have a question regarding the uploading of files to a ASP.Net & SQL 2k5 based application. After the user uploads their file to the server, I usually save the file name in a table, and rename actual file to match the unique ID of the promotion (1 attachment per promotion). This way I don't have to worry about duplicate filenames. However, when they hover over the link to view the attachment, they will see the path the actual file, which is /folder/123 instead of /folder/yourattachment.pdf. Which in turn makes it difficult for the browser to know which application to open the attachment with. Is there a workaround for this? Something like renaming the file just in time? Or copying the file to a temporary location and renaming it? Or do most people have a seperate folder for each record (promotion)? Thanks, Rob
  3. I'm looking to create a central business object that will be used by most of our internal web applications. In doing my research, it seems that a web service will offer the most flexibility while still allowing a central location to host and maintain. My question is; is this the best choice? I'm looking to consolidate common functionality such as employee details, database access, and logging. If it is the best choice, how do I handle instances where I want to return a custom class from the web service? For example, lets say I want to return an employee object. I'm trying to avoid having to update each client application everytime we change something on the web service. Or should I just move everything into datasets or XML even though I lose Intellisense? Thanks, Rob
  4. I have been going back on forth on a design issue. I have a helpdesk solution used by our company that is simply a VB client & a SQL backend that runs on our LAN. I am attempting to rewrite it in 2005 (from 2003) to learn more about the new 2.0 framework and whatnot. My question is, what is a more efficient way for concurrent users to communicate when the add/edit/delete tickets? Currently I have a timer control that fires off every X minutes to query the DB and look at the update date on the record. Anything new/updated/deleted gets returned in a disconnected recordset and I process this on the client making the appropiate changes to the ticket listing. It works well, but I wonder if it is slow due to the constant queries. I have been thinking of a second choice with a server service that utilizes messaging. I don't have much experience in this, but I'm sure I could figure it out. But basically, when the client makes a change, it would send a message to the server service, which would then send out a broadcast to any other clients that may be logged in. This scenerio gets rid of unncessary SQL querries, and seems to be more efficient. Does anyone have any quidance or suggestions? If the messaging is the way to go, does anyone know of a solid tutorial? Is there another option I am missing? TIA, Rob
  5. I have a table control that I am dynamicaly adding rows to - which I am building off a session variable that is a datatable. At the end of each row I am adding an imagebutton that will delete the row from both the table and the session datatable. I have it working the first time a user clicks on any of the imagebuttons, but on a second imagebutton click my event is not fired, but I do get a postback. If I click a third time it works as expected, and a fourth click will not raise the event again. In my page_load event I am simply building the table (not checking for postback). In my img_click event I am finding the corresponding row in my session datatable, deleting it, and reloading my table. Here is where I am adding my imagebutton cell = New TableCell Dim img As ImageButton = New ImageButton img.ImageUrl = "img/remove.gif" img.CommandName = "onClick" img.CommandArgument = dr.Item("myID") img.ToolTip = "Remove from cart" AddHandler img.Click, AddressOf img_Click cell.Controls.Add(img) cell.Width = New Unit(25) cell.HorizontalAlign = HorizontalAlign.Right row.Cells.Add(cell) Me.tblMain.Rows.Add(row) So why is my img_click event only fireing every other time? Thanks, Rob
  6. I am using interop to create an Excel spreadsheet. How can I set my page setup to select the "Fit To..." option? I am using the following code to set the page count width & height, but the radio button is not selected. 'FYI - oSheet is an Excel.WorkSheet oSheet.PageSetup.FitToPagesTall = 100 oSheet.PageSetup.FitToPagesWide = 1 oSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape Thanks, Rob
  7. When using a calendar control, the user is also showed the ending days from the previous month and the starting days from the next month. IE - when viewing 12/04, the user actually sees 11/28/04 - 1/8/05. How can I get these values in the page load event? I want to open a dataset for the month so I can draw items in the DayRender event. Thanks, Rob.
  8. rbb

    Calendar entries

    I removed and readded the control and everything is as expected.
  9. I have begun using the calendar control, but I have discovered that any text I add during the dayrender event is being wrapped way to early. Each day column is 200px wide, but the text "Class 101 (0/9)" is being wrapped before the paranthesis. No matter how wide I make my day columns, it is always the same thing. Here is my DayRender event Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender Dim sb As System.Text.StringBuilder If e.Day.Date.Day = 18 Then sb = New System.Text.StringBuilder("<br>") sb.Append("<a href='http://www.msn.com'>Class 101 (0/8)</a><br>") sb.Append("<a href='http://www.yahoo.com'>Class 123 (2/6)</a><br>") sb.Append("<a href='http://www.edmunds.com'>Class 563 (6/6)</a><br>") sb.Append("<a href='http://www.edmunds.com'>Class 666 (1/12)</a><br>") e.Cell.Controls.Add(New LiteralControl(sb.ToString)) End If End Sub Thanks, Rob
  10. rbb

    Summarize Data

    I acutally ended up using a dataset. Thank you for the replies though. Rob Dim ds as DataSet ds = New DataSet Dim myColumn As DataColumn Dim d(1) As DataColumn ds.Tables.Add("tmp") myColumn = New DataColumn myColumn.ColumnName = "year-month" myColumn.DataType = GetType(String) myColumn.Unique = True ds.Tables("tmp").Columns.Add(myColumn) d(0) = myColumn myColumn = New DataColumn myColumn.ColumnName = "count" myColumn.DataType = GetType(Integer) myColumn.DefaultValue = 0 ds.Tables("tmp").Columns.Add(myColumn) ds.Tables("tmp").PrimaryKey = d 'And later on... With ds.Tables("tmp") dr = .Rows.Find(my_Date) If dr Is Nothing Then dr = .NewRow dr(0) = my_Date dr(1) = Integer.Parse(my_Counter) .Rows.Add(dr) Else dr(1) += Integer.Parse(Counter) End If End With
  11. I am trying to get the number of entries per hour in a log file. The data looks like this: 12/5/04 8:15 AM - blah blah blah ... 12/5/04 8:50 AM - blah blah blah ... 12/5/04 10:59 AM - blah blah blah The results should be something like Date - Count 12/5/04 8 AM - 15 12/5/04 9 AM - 21 12/5/04 10 AM - 2 In VB6 I used to create a temporary ADO recordset to summarize data. I would filter by the date, and if a match was found, increment the counter. Otherwise, create a new record and set its counter to one. The question is - what is the proper way to do this same summarizing in .Net? Arraylist, DataSet? And can you please provide an example? Thanks, Rob
  12. I have written a fairly detailed app that takes an inventory of a system, which we our using for company deployed machines. Using our Novell network, we push the app out during their login. The problem comes from our remote locations - they won't log onto the network for weeks at a time because it takes quite a few minutes to actually log in over the WAN. So, my question is can I silently copy this app into a directory and make a registry change to have it run on startup? Our company policy for IE intranet security settings is to have it on low, so the possibility of IE blocking it is minimized. The reason I ask is because every employee hits my intranet site whether they logged into the network or not, and it seems to be the best platform to distribute. Thought? Concerns? Thanks, Rob
  13. I have a table that includes a bit column, and a stored procedure that inserts records into this procedure. I am now trying to write the code in VB.Net, but I am getting the following error every time I try to use a SQLDBType.Bit parameter. An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll Additional information: System error. So I wrote some test code, and here it is. VB CODE Private Sub TestBit() Dim cn As SqlConnection Dim cmd As SqlCommand cn = New SqlConnection(g_DBConnection) cn.Open() If cn.State = ConnectionState.Open Then cmd = New SqlCommand("up_insert_crap") cmd.Connection = cn Dim p As New SqlParameter("@crap", SqlDbType.Bit) p.Value = 1 cmd.Parameters.Add(p) cmd.ExecuteNonQuery() cn.Close() End If End Sub SQL SP create procedure up_insert_crap @crap bit as insert into tblcrap(test) values(@crap) The table is just an identity id field and a test field that is a bit. Any Ideas as to what I am doing wrong? Thanks, Rob
  14. Does anyone know how I can modify the forecolor of a disabled combobox? The grey on grey is difficult to read, and disabled textboxes use a black forecolor for better contrast. Thanks, Rob
  15. No - its just a standard windows application. If I continue using my application, it does not seem to create any new connections.
  16. In my CommandExecuteReturnDataSet event I am opening the connection, grabbing the data, and closing the connection. I also tried the following with the same results: Public Function CommandExecuteReturnDataSet2() As DataSet Dim cn As SqlConnection Dim ds As New DataSet Dim da As SqlDataAdapter cn = New SqlConnection(strConnection) cn.Open() If cn.State = ConnectionState.Open Then cmd.Connection = cn da = New SqlDataAdapter da.SelectCommand = cmd da.Fill(ds, "data") da.Dispose() cn.Close() End If cn.Dispose() Return ds End Function Why does cn.Open() actually open two (2) connections to SQL Server (both with ProgramName of .Net SqlClient Data Provider)? Thanks again, Rob
  17. I have created a class that encapsulates all the calls to my database. The guts of it look like this (at least for reading data): Public Class clsData Private strConnection As String Private cn As SqlConnection Private cmd As SqlCommand Public Sub New(ByVal str As String) strConnection = str End Sub Private Function OpenDB() As Boolean If IsNothing(cn) Then cn = New SqlConnection(strConnection) cn.Open() If cn.State = ConnectionState.Open Then OpenDB = True End If End Function Private Function CloseDB() As Boolean If Not IsNothing(cn) Then If cn.State = ConnectionState.Open Then cn.Close() cn.Dispose() CloseDB = True End If End Function Public Function CommandExecuteReturnDataSet() As DataSet Dim ds As New DataSet Dim da As SqlDataAdapter If OpenDB() Then cmd.Connection = cn da = New SqlDataAdapter da.SelectCommand = cmd da.Fill(ds, "data") da.Dispose() CloseDB() Return ds End If End Function Public Function CommandCreateSP(ByVal sp As String) As Boolean cmd = New SqlCommand cmd.CommandText = sp cmd.CommandType = CommandType.StoredProcedure End Function End Class My calling code looks like this: Dim cls As clsData Dim ds As DataSet cls = New clsData(g_DBConnection) cls.CommandCreateSP("up_select_main_form") ds = cls.CommandExecuteReturnDataSet cls = Nothing If Not ds Is Nothing Then 'Do stuff here End If ds.Dispose() The problem is, when I make the call to cls.CommandExecuteReturnDataSet, I expect the SQL connectino to open, grab the data, and close. But if I run a sp_who2 on my SQL Server, I have TWO connections open, and they just don't go away until after the app closes. Does this have anything to do with connection pooling? In an effort to make my apps more robust, I want to open and close connections JIT to minimize network traffic and whatnot. Any ideas? Thanks, Rob
  18. Option Strict is turned off, but the working code does pass an actual value and works as expected. If it turn Option Strict on, it does give me an error. Seems to be unpredictable results. I will move to a method based on Nerseus's suggestion. Thanks Rob
  19. I have a class that accepts a command parameter as a parameter. Private cmd As SqlCommand Public Sub AppendParameter(ByVal p As SqlParameter) cmd.Parameters.Add(p) End Sub The following code works perfectly: cls.AppendParameter(New SqlParameter("@id", SqlDbType.VarChar, 25).Value = str) But this code gives me a "Specified cast is not valid." error cls.AppendParameter(New SqlParameter("@Manufacturer_ID", SqlDbType.Int).Value = 1) If I create a parameter object and pass that, it works just fine. Any ideas? Thanks, Rob
  20. I am trying to create a data class that will return xml instead of datareaders in an effort the make everything lightweight. One of my ideas is to return any storedprocedures that result in multiple recordsets in the following fashion: <DATA> <RESULT1> <ROW> <ID>2</ID> <Name>Compaq</Name> </ROW> <ROW> <ID>1</ID> <Name>Dell</Name> </ROW> </RESULT1> <RESULT2> <ROW> <ID>7</ID> <Name>Windows 95</Name> </ROW> <ROW> <ID>6</ID> <Name>Windows 98</Name> </ROW> </RESULT2> <RESULT3> <ROW> <ID>13</ID> <Name>166MHz</Name> </ROW> <ROW> <ID>15</ID> <Name>233 MHz</Name> </ROW> <ROW> <ID>16</ID> <Name>300 MHz</Name> </ROW> </RESULT3> </DATA> First of all, does anyone agree with my strategy? Secondly, how can I loop through result1, then result2, and so on. I found the following sample code, but it only works for 1 level. nodeList = xmlDoc.SelectNodes( .GetElementsByTagName("ROW") For Each node In nodeList Console.Out.Write(node.ChildNodes(0).InnerText) Console.Out.Write(node.ChildNodes(1).InnerText) Next Thanks, Rob
×
×
  • Create New...