|
Agreed. When picking tools that are going to become a part of your development process you should choose very carefully, because its going to be hard to back out of it. Also a lot of tools are very complex to use - meaning a great deal of time is spent configuring and babysitting the tools.
Personally I am usually not comfortable using a tool that does more than one thing. Nothing is worse than installing a tool to handle your data layer that ends up restricting how you do things in the UI.
If you are interested in an ORM product thats not overbearing for use in smaller applications, I suggest you give Diamond Binding a test drive.
|
|
|
|
|
Mark Churchill wrote: your data layer that ends up restricting how you do things in the UI
agreed
but you can do it another way too.
for example my data layer has a factory class that contains a getdataset command
where I pass the datarequest command (in the form of MS SQL) , the connection as an object and the dataprovider type)
there are families of classes for each dataprovider
so for example I have an OracleViaWebservice family which takes the MS SQL command, converts it to oracle SQL, uses the connectio class to find identify the correct web service location and passes the request to the web service which then uses the oracle connectstring (stored in that connection class) and issues the comand aainst an oracle DB before returning the result.
now all that took time but now its written Its very extendable.
If I come across a new dataprovider (ie webservice to Siebel for example) I just create a new family of generic classes to handle the process and away I go.
If I come across another type of dataaccess (ie instead of processing a dataset, I need to process a er DataReader - yeah I know its a reach) then I just add the procesing code for a datareader to each existing family of classes
I find that the ongoing maintenance of my data layer is practically non existant now and its generic enough not to restrict my business layer.
Martin
life is a bowl of cherries
go on take a byte
|
|
|
|
|
ADODB.RecordSet.RecordCount()
Im confused about this function
ADODB.Recordset.RecordCount???? this code below is working in VB.Net 2003
and the my recordset "dbRecordset.RecordCount" returns "0" or "1" output value only...
but then when i copy this code and used to VB 2005??? it count to what ever records it fetch from the database table...
for example: expect that there's only 1 record inside the table? yes it returns 1's value but then after that countdown it returns agained to "ZERO"
so my IF and ELSE condition were executing both???? which is something elogical???
**********************************
frmLogin.vb
*******************************
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
Dim dbConnection As New ADODB.Connection
Dim dbRecordset As New ADODB.Recordset
Dim strDBPath as string
Dim strSQL As String
strDBPath = "c:\database\sample.mdb"
strSQL = "SELECT * FROM tblUser WHERE UserName='" & strUsername & "' and Password='" & strPassword & "';"
dbConnection.Mode = ConnectModeEnum.adModeReadWrite
dbConnection.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data source="& strDBPath)
With dbRecordset
.Open(strSQL, dbConnection, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, -1)
If .RecordCount = 0 Then
MsgBox("Incorrect username & password" & vbTab, MsgBoxStyle.Exclamation, "Log-in Failed")
Else
frmMain.Show()
Me.Close()
End If
.Close()
End With
dbConnection.Close()
End Sub
*****************************************
Please Help...
Please be patient, im a newbie in VB...
Thanks in advance....
|
|
|
|
|
First things first...
WTH are you still using ADODB Recordsets?!?!
|
|
|
|
|
Not actually using ADODB before... but i am little bit force to follow this kind of database connections, there's is an existing system that is using ADODB connections that i am maintainning as of now.. So i have no choice but to follow the direction of the wind... ehehe otherwise? i have to change all database connections of the former programmer of that system i've said so.. and it seems i need to overwhole that program if i do that...
ADODB.RecordSet.RecordCount always return 0 or -1
|
|
|
|
|
Hi,
I am trying to draw a webpage to a bitmap without showing it to the user. I know the webbrowser control doesnt support the DrawToBitmap function but I found this really helpful post on codeproject that showed how to go about it. Firstly, it required the calling of the interface from MSHTML:
<interfacetype(cominterfacetype.interfaceisiunknown)> _
<guid("3050f669-98b5-11cf-bb82-00aa00bdce0b")> _
Public Interface IHTMLElementRender2
Sub DrawToDC(ByVal hdc As System.IntPtr)
Sub SetDocumentPrinter(ByVal bstrPrinterName As String, ByRef hdc As _RemotableHandle)
End Interface
and then i did the following in the document_complete event:
Dim rawDoc As IHTMLDocument2 = DirectCast(wBrowser.Document.DomDocument, IHTMLDocument2)
Dim rawBody As IHTMLElement = rawDoc.body
Dim render As IHTMLElementRender2 = DirectCast(rawBody, IHTMLElementRender2)
Dim screenCapture As New Bitmap(Me.Width, Me.Height)
Dim drawRectangle As New Rectangle(0, 0, Me.Width, Me.Height)
wBrowser.DrawToBitmap(screenCapture, drawRectangle)
Dim grap As Graphics = Graphics.FromImage(screenCapture)
Dim graphicsHdc As System.IntPtr = grap.GetHdc()
render.DrawToDC(graphicsHdc)
Now the problem. It is working fine accept for sites such as ask.com (where it shows a blank bitmap) and wikipedia.org ( where it just shows Wikipedia on the top). I have an idea as to why this is happening. I believe its cause these sites somehow donot house their content on the document body which I am painting. Any idea as to how this can be rectified?
Thanks!
Ahmad
|
|
|
|
|
And I think its due to the DocType Tag on these sites. Anyway around it?
|
|
|
|
|
I'm building a project in VB2005 and I need the DrawEdge function. Its a win32 API call. I cammot get it working. It seems that the parameter RECT is giving the troubles.
Declaration:
Private Declare Auto Function DrawEdge Lib "user32" (ByVal hdc As IntPtr, ByRef qrc As Rectangle, ByVal edge As Integer, ByVal grfFlags As Integer) As Integer
Usage:
Dim rc As New Rectangle(100, 100, 100, 100)
Dim hDC As IntPtr
hDC = g.GetHdc
Call DrawEdge(hDC, rc, BDR_SUNKEN, BF_RECT)
g.ReleaseHdc(hDC)
Does anyone knows whats wrong
best regards,
Koos.
|
|
|
|
|
I think you need to also define the RECT struct. I'd recommend looking at www.pinvoke.net, they probably have the code you need.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi, i am new vb learner and i want to change date variable to string variable is there any build in function in vb6?
|
|
|
|
|
If you're new, I recommend dropping VB6, which is obsolete, unsupported and nasty. VB.NET 2005 express edition is free from Microsoft.
And, in VB.NET, the ToString method would do what you're after.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
CStr(yourdate) should do it.
That said I 100% agree with Christian. Don't learn VB6 - it will only teach you bad practices. And why bother when Visual Studio Express is free?
|
|
|
|
|
Hello I'm trying to get time difference for each record in my datagrid - but I'm currently having problems with my loop - I'm only getting the time difference for the first record - Help will be really appreciated. In this example I'm using a for each - any ideas will be great...
Dim d1 As DateTime = conv
Dim d2 As DateTime = System.DateTime.Today
Dim subtract, absday
subtract = 0
'gworkdays = DateDiff("d", d1, d2)
Dim rec As DataRowView
'Dim x As Integer
'Do Time Calculation for each record
For Each rec In dgOrderReport.DataSource
Select Case DatePart("w", d1)
Case 1
subtract = subtract + 1
Case 7
subtract = subtract + 2
End Select
Select Case DatePart("w", d2)
Case 1
subtract = subtract + 2
Case 7
subtract = subtract + 1
End Select
absday = DateDiff("d", d1, d2) + 1 - subtract
fncGetDays = absday - CInt(2 * (absday \ 7))
If fncGetDays < 0 Then fncGetDays = 0
'x = x + 1
Next rec<code></code>
Thank You
|
|
|
|
|
KA National Marker wrote: For Each rec In dgOrderReport.DataSource
rec is your record - where in your code do you use this value ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
As of right now in the above code rec is set as my DataRowView
'Dim rec As DataRowView ~~~ which not correct what so ever
I'm really having problems with the syntax with the FOR Loop
Thank you for the response.
Thank You
|
|
|
|
|
The issue is, you're using a for loop to iterate over the data, rec each time is a datarowview. I'm not familiar with this class, but I assume it represents a view into a row of your data. So, my question was, why are you not using this variable to access data from that row, which is surely what the loop is for ? Unless there's some VB magic going on here, you ignore the 'rec' variable which presumably contains the values for the row you want to process, which means you process the same data each time ( whatever that is )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'm still not 100% getting it...Also I'm not really familiar with this DataRowView class I've seen it used for datagrid search in the past I believe.
I dont believe I'm ignoring the rec variable. Unless your saying within that loop I will have to tell it to go to the next rec? Make Sense...
Dim rec As DataRowView
'Dim x As Integer
'Do Time Calculation for each record
For Each rec In dgOrderReport.DataSource
Next rec<code></code>
Thank You
|
|
|
|
|
KA National Marker wrote: I dont believe I'm ignoring the rec variable.
Where do you reference it within the loop ? You reference d1 and d2, which are never changed. So, you will end up with the same values each time.
For Each rec In dgOrderReport.DataSource
Select Case DatePart("w", d1)
Case 1
subtract = subtract + 1
Case 7
subtract = subtract + 2
End Select
Select Case DatePart("w", d2)
Case 1
subtract = subtract + 2
Case 7
subtract = subtract + 1
End Select
absday = DateDiff("d", d1, d2) + 1 - subtract
fncGetDays = absday - CInt(2 * (absday \ 7))
If fncGetDays < 0 Then fncGetDays = 0
'x = x + 1
Next rec
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I now understand exactly what you mean about not referencing 'rec' within my loop - I wasn't able to successfully reference it because of the lack of knowledge I have with the Class I was using so I changed the code just a bit -
I decided to use a the currency manager to count each row, and I'm now using a do while - now my problem is my specified cast is not valid - which I'm assuming is because I'm using the wrong class for rec to compare it to my datagrid...Help will be great - Thanks...
Dim rec As Object
Dim cm As CurrencyManager = CType(BindingContext(dgOrderReport.DataSource), CurrencyManager)
Dim rowcount As Integer = cm.Count
Dim row As Integer = 0
Do While row < rowcount
For Each rec In dgOrderReport.Item(row, 3)
Select Case DatePart("w", d1)
Case 1
subtract = subtract + 1
Case 7
subtract = subtract + 2
End Select
Select Case DatePart("w", d2)
Case 1
subtract = subtract + 2
Case 7
subtract = subtract + 1
End Select
absday = DateDiff("d", d1, d2) + 1 - subtract
fncGetDays = absday - CInt(2 * (absday \ 7))
If fncGetDays < 0 Then fncGetDays = 0
row = +1
Next rec
Loop<code></code><code></code>
Thank You
|
|
|
|
|
Hi All,
I have list of html files for online documentation of VBA.
Can any one tell me how to generate *.chm file from html files.
I am trying to get Dynamic Help using Ctrl+F1 using chm file.
Also how to link the chm file to Ctrl+F1 key?
Thanks In Advance.
|
|
|
|
|
Look for .chm compiler. I think it may allow you to convert .html, I'm not 100% on that.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
'''
''' Populates the DataGridView
'''
Private Sub PopulateDataGridView()
' Set the column header names.
userAccessGrid.ColumnCount = 5
userAccessGrid.RowsDefaultCellStyle.BackColor = Color.White
userAccessGrid.RowHeadersVisible = True
userAccessGrid.Name = "User Access Grid"
userAccessGrid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Raised
userAccessGrid.CellBorderStyle = DataGridViewCellBorderStyle.Raised
userAccessGrid.ColumnHeadersHeight = 20
' Initialize basic DataGridView properties.
userAccessGrid.Dock = DockStyle.Fill
userAccessGrid.BackgroundColor = Color.LightGray
userAccessGrid.BorderStyle = BorderStyle.Fixed3D
userAccessGrid.Columns(0).Name = "AccessLevelDescription"
userAccessGrid.Columns(0).DataPropertyName = "AccessLevelDescription"
userAccessGrid.Columns(0).Width = 40
userAccessGrid.Columns(0).HeaderText = "Access Level Description"
userAccessGrid.Columns(0).DefaultCellStyle.Font = New Font("Arial", 7, FontStyle.Regular)
userAccessGrid.Columns(1).Name = "NoAccess"
userAccessGrid.Columns(1).DataPropertyName = "NoAccess"
userAccessGrid.Columns(1).Width = 40
userAccessGrid.Columns(1).HeaderText = "No Access"
userAccessGrid.Columns(1).DefaultCellStyle.Font = New Font("Arial", 7, FontStyle.Regular)
userAccessGrid.Columns(2).Name = "ReadOnly"
userAccessGrid.Columns(2).DataPropertyName = "ReadOnly"
userAccessGrid.Columns(2).Width = 40
userAccessGrid.Columns(2).HeaderText = "Read Only"
userAccessGrid.Columns(2).DefaultCellStyle.Font = New Font("Arial", 7, FontStyle.Regular)
userAccessGrid.Columns(3).Name = "NormalAccess"
userAccessGrid.Columns(3).DataPropertyName = "NormalAccess"
userAccessGrid.Columns(3).Width = 40
userAccessGrid.Columns(3).HeaderText = "Normal Access"
userAccessGrid.Columns(3).DefaultCellStyle.Font = New Font("Arial", 7, FontStyle.Regular)
userAccessGrid.Columns(4).Name = "TotalAccess"
userAccessGrid.Columns(4).DataPropertyName = "TotalAccess"
userAccessGrid.Columns(4).Width = 40
userAccessGrid.Columns(4).HeaderText = "Total Access"
userAccessGrid.Columns(4).DefaultCellStyle.Font = New Font("Arial", 7, FontStyle.Regular)
userAccessGrid.SelectionMode = DataGridViewSelectionMode.CellSelect
userAccessGrid.MultiSelect = False
userAccessGrid.BackgroundColor = Color.LightBlue
userAccessGrid.ColumnHeadersDefaultCellStyle.Font = New Font("Arial", 8, FontStyle.Regular)
'--------------------------------------------------------------------------------------------
Dim appdesc_selectStatement As String = "Select access.level, pas_appitem FROM(access)Where access.uname = '' ORDER BY appitem"
Dim level_selectStatement As String = "Select accitem.appdesc, acclevels.level, accitem.appitem FROM(accitem, acclevels, access)Where access.uname = '' And accitem.appitem = access.appitem And access.level = acclevels.level Order By accitem.appitem"
Dim dt_Appdesc As New DataSet()
v = clsDataAnalyzerJetOleDb.MSAccessOleDb.PopulateDataSet(appdesc_selectStatement)
Dim dt_Level As New DataSet()
dt_Level = clsDataAnalyzerJetOleDb.MSAccessOleDb.PopulateDataSet(level_selectStatement)
Dim ds As DataSet = New DataSet()
Dim Dt_UserAccessDataSet As New DataSet()
Dim DescriptionColumns() As DataColumn = New DataColumn() {ds.Tables(0).Columns("appitem"), ds.Tables(0).Columns("appdesc")}
Dim AccessLevelColumns() As DataColumn = New DataColumn() {ds.Tables(1).Columns("level"), ds.Tables(1).Columns("desc")}
Dim Tran_Detail As New DataRelation("DescriptionColumns", ds.Tables(0).Columns("AccessLevelDescription"), AccessLevelColumns(1).Columns("No Access", "ReadOnly", "NormalAccess", "TotalAccess"))
'Dim tablearray() As DataTable = New DataTable(3) {}
'tablearray(0) = dt_Appdesc.Tables("appitem")
'tablearray(1) = mySecondDataSet.Tables("AnotherTable")
'tablearray(2) = myThirdDataSet.Tables(0)
'get a DataTableReader over these tables
'myDataTableReader = myFirstDataSet.GetDataReader(tablearray)
' Section for filling the Fields after the Data has been looped and read into the Grid
Dim OleDBConn As OleDbConnection = New OleDbConnection(MSAccessOleDb.ConnectionString())
OleDBConn.Open()
Dim cmd As OleDbCommand = New OleDbCommand("appdesc_selectStatement", dt_Appdesc)
Dim daTransactions As OleDbDataAdapter = New OleDbDataAdapter(cmd)
daTransactions.Fill(ds, "dt_Appdesc")
Dim cmdDetails As OleDbCommand = New OleDbCommand("level_selectStatement", dt_Level)
Dim daTransactionDetails As OleDbDataAdapter = New OleDbDataAdapter(cmdDetails)
daTransactionDetails.Fill(ds, "dt_Level")
DataRelations(Of String, DescriptionColumns(), AccessLevelColumns(), Boolean)()
Dim dx As New DataGridViewTextBoxColumn() = New DataGridViewTextBoxColumn()
'Pass in ds as DataSet, and "Transactions as TblName
Dim userAccessDataRow As DataRow = dt_Appdesc.NewRow()
Dim userAccessDataAdapter As New OleDbDataAdapter()
For Each userAccessDataRow As DataRow
Dim i As Integer
For i = 0 To dt_Appdesc.Rows.Count - 1
'Loop through Query B
'For each Row in DataTableB
For Each userAccessDataRow As DataRow In userAccessTable.Rows
'The level from the query associates to the proper checkbox in the row
accessQuery = accessQuery + 1
'Loop Through Query A's DataTable
i = 0
For Each userAccessDataRow In userAccessTable.Rows
userAccessTable.Columns(1)(0) = userAccessDataRow(0)(1).value
'i = i + 1 'So, that we continue looping
'Level2 = Row(0).value
'If Level2 = Level1 Then 'Set the level
CheckBox in Column(1)
Exit For
Exit For
Next
Next
Next
Next
Try
' Section for filling the Fields after the Data has been looped and read into the Grid
If dt_Appdesc.Rows.Count = 0 Then
Dim OleDBConn As OleDbConnection = New OleDbConnection(GetOleDBConn())
OleDBConn.Open()
userAccessDataAdapter.SelectCommand = New OleDbCommand(appdesc_selectStatement, OleDBConn)
userAccessDataAdapter.Fill(dt_Appdesc)
userAccessDataAdapter.InsertCommand = New OleDbCommandBuilder(userAccessDataAdapter).GetInsertCommand()
userAccessDataRow("uname").Trim()
dt_Appdesc.Rows.Add(userAccessDataRow)
OleDBConn.Close()
OleDBConn.Dispose()
Else
Throw (New Exception("Error attempting to insert duplicate data."))
End If
Catch messerr As Exception
Call ShowErrorMessage(messerr, "listboxUserGroup_SelectedIndexChanged", "frm_security")
End Try
' Add the rows to the DataGridView.
Dim rows() As Object = {}
Dim rowArray As Object()
For Each rowArray In rows
userAccessGrid.Rows.Add(rowArray)
Next rowArray
' Adjust the row heights so that all content is visible.
userAccessGrid.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders)
End Sub
Here's my nasty 150 line DataSet, DataRelation, DataObject, DataBullshit problem. As you can tell, this isn't the first day that I've been working on this function. If you have any bones to through in my general direction, I'd be incredibly grateful. My goal is to get a two Datasets and combine them after I take the user access level and turn it sideways. Then populate the gridview, then I'm going to write back to the database from the selected values.
Gridview looks like
Appdesc NoAccess Read-Only Normal Total Access
blah blah X X X X
blah blah X X X X
|
|
|
|
|
Is this written in Access VB, VB6 or VB.NET ? A lot depends on the answer to this question. You are right about one thing though, this is nasty. (You have actually hard coded the entire gridview.)
I will throw you this bone: get .Net Studio, put a datagrid on a form, link it to your dataset, and populate the dataset. Of all the code, you will only have to write about 20 lines, if that much.
Necessary changes can be made directly to the dataset structure, or the database, and your grid will adapt itself to the changes.
If you are already using a version of .net studio, then you really need to let go of these old vb6 habits.
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi everybody. I'm using enterprise library 3.1 and vb 2005. I want to build a data access layer but I don't know where I can start.
It's my first time using patterns so I hope you can help me.
I had installed and build the application block but I don't know how use them.
JESHU
-- modified at 17:47 Tuesday 21st August, 2007
|
|
|
|
|