|
OK - you told me you were writing code. You're not, you're using some sort of wizard.
We're back to the point where the only advice I can offer is to write your own data layer, in code. Hopefully, someone who uses the stuff you're choosing to use can offer some other advice.
Here's an example that uses a stored proc:
http://www.developersdex.com/gurus/code/479.asp[^]
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Yes, the right way to do data access is stored procs, which take parameters.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
campbells wrote: I have create the global variable for User option which suppose will refer to param1 and param2...
Is this VB6, or by global do you just mean a public variable on a class ? Either way, this is bad design, you should do better.
I would suggest the best thing to do is to write your own SQL code ( which also means you can put it in a data layer where it belongs ), then you won't be fighting a wizard.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
campbells wrote: but~sure i cant put it like that cause the data command SQL will not regonize wat it the cfrom and cto variable
If you're just creating SQL, remember you're creating a static string, it's not going to be parsed. You need to make sure you're passing in the VALUE of your variable, and not it's name
s = s & " where bizdate<=" & cfrom & " and bizdate >= " & cto
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
OK - it's VB6 ? No, I would attack anyone who tried to put that on my machine
Like I said, sounds like your playing with wizard generated stuff, this never happens to me when I deal with databases entirely in code, and the other bonus is, I get to have a proper data layer.
I don't know what the Microsoft data environment is, but it sounds hideous. Hopefully, someone else knows more and can give you more specific help for the approach you're taking.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello all,
Perhaps you can help me. I have a com object which I converted from VB6 to VB.NET. I am using this com object with other .Net applications without any problem. However, I am now trying to use this com object in some old ASP code which I have not yet converted. I want to use the com object because it contains some additional functionallity that the original com object did not possess. The ASP code works fine when calling the old com object. BUT..if I change the code to call the new com object, it takes a very very (60secs.) long time for the object to be instantuated. In other words, when the code hits the CreateObject line, it takes 60 secs to execute. The rest of the calls to the methods of that com object execute normally. What am I doing wrong? I am including code snipplets of both the VB.NET com object and the ASP page.
Thank you in advance.
Michael Gisonda
VB.NET---------------------
Option Strict Off
Option Explicit On
Imports System.EnterpriseServices
Imports System.Reflection
Imports System.Runtime.InteropServices
<assembly: assemblyversion("3.0.0.0")="">
<assembly: comcompatibleversionattribute(1,="" 0,="" 0)="">
<assembly: applicationname("estsyspro_net")="">
<assembly: assemblykeyfileattribute("n:\projects\estimpact.net\bin\estsyspro.snk")="">
<system.runtime.interopservices.progid("estsyspro_net.custinfo")> Public Class Custinfo
Inherits ServicedComponent
Private gImpConn As ADODB.Connection
Private mConnection As Object
<autocomplete()> Public Function GetBlanketContractInfo(ByVal contract As String, ByVal stockcode As String, Optional ByVal companyid As String = "L") As ADODB.Recordset
Dim sSQL As String
Dim rsRetRecord As New ADODB.Recordset
Dim rsGetRec As New ADODB.Recordset
Dim lLocalConnection As New ADODB.Connection
'Take the company id provided by the user and make it capitalized and only the first letter.
companyid = UCase(Trim(Mid(companyid, 1, 1)))
'Set the connection string to the proper company based on the companyid
lLocalConnection.ConnectionString = fnGetConnectionString(companyid)
'Open the connection.
lLocalConnection.Open()
sSQL = "SELECT SorContractPrice.ContractType, SorContractPrice.StockCode, " & "SorContractPrice.Contract, SorContractPrice.StartDate, " & "SorContractPrice.ExpiryDate, SorContractPrice.PriceMethod," & "SorContractPrice.FixedUom, SorContractPrice.FixedPriceCode, " & "SorContractPrice.FixedPrice " & "FROM SorContractPrice " & "WHERE SorContractPrice.Contract= '" & contract & "' " & "AND SorContractPrice.StockCode= '" & stockcode & "'"
rsGetRec = lLocalConnection.Execute(sSQL)
If Not rsGetRec.BOF And Not rsGetRec.EOF Then
rsRetRecord = MakeRS(rsGetRec)
OpenAndFillRS(rsGetRec, rsRetRecord)
Else
rsRetRecord = Nothing
End If
'Clean up
rsGetRec.Close()
rsGetRec = Nothing
lLocalConnection.Close()
lLocalConnection = Nothing
GetBlanketContractInfo = rsRetRecord
End Function
End Class
END VB.NET -----------------------------------------
ASP Code -------------------------------------------
if mcountrycd="001" then
mCountryLbl="L"
else
mCountryLbl="M"
end if
'vvv This line takes 60 secs to execute.
Set IMPC = server.createobject("EstSyspro_NET.CustInfo")
'vvv This line executes normally.
Set IMPCUST = IMPC.GetBlanketCustInfo(Trim(mSysproCustomer),mCountryLbl)
if IMPCUST is nothing then
......
.....
End ASP Code ---------------------------------------
|
|
|
|
|
Really, I don't think you're doing anything wrong, but I'm no expert on ASP. It seems that on that GetObject statement, the NET Framework has to loaded into the ASP process on the server. This can take quite a long time. Depending on the machine config, I've seen .NET 2.0 load times take about 30 seconds, so this could be part of your problem.
After the page successfully loads and gets through this code, try refreshing it or open a new browser window and load the same page. If the second browser window gets through the page quickly (or as expected), this is probably your problem, but unfortunately, I think you're stuck with it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have tried that, unfortunitely I get the same result.
Mike
|
|
|
|
|
Is there a way I can change only the font size of the contents in a Rich Text box? I've tried using
MainTxt.Font = New Font(MainTxt.Font.Name, 12) but that still removes any bold, italics, etc.
Any thoughts would be greatly appreciated.
Thanks for your time,
Brian
|
|
|
|
|
If you go in to the design view of the form and go in to the property of the rich text box. You can set the font size under Font property. Or you can set the font size in the load method of that form. by:
RichTextBox1.Font = New Font(RichTextBox1.Font.Name, 5)
---------------------------------
There is life outside coding.
|
|
|
|
|
The problem with that is the contents of the Rich Text Box, an rtf file, is loaded and reloaded several times throughout the program.
|
|
|
|
|
Maybe you can first select all the text, and then change the selectionfont.
'Dunno if this works:
'select all text
rtb.SelectionText = rtb.Text
'change font (only size so use old font)
'i don't know what happens if there are different fonts involved in the selection..
rtb.SelectionFont = New Font(rtb.SelectionFont, 12.0!)
'deselect the text
rtb.SelectionLength = 0
You could also look at the RichTextBoxExtended article.
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
Same thing, lost the bold and styles.
|
|
|
|
|
Using just the standard RTB control, you'll have to go through each part of the text and see if the font changes from the previous font style. Say you have a length of text and only the middle 1/3 of the text is in a different style. You'd have to do 3 font changes. Select the first part of the text, change it's font size by creating a new font using the name and styles of the existing font. Then find the next section of text based on its Font, change it's font, then find the last section of text and do the same.
Not very efficient, huh? Your only alternative is to replace the RTB with an extended version of the control that offers, well, more control over the editing capability of the text.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Crap.
You could do it one char at a time, but i think it's going to be slooooooow.
I'm going to bed now, good luck with it
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
Yeah it is!!
The way to do it, without the RTB is to represent the Text and formatting in a data structure behind the scenes, then render the visible version using that data. It then makes changing the font, or pieces of it, in sections very easy since you're not hunting for the changes in the font through out the text. The code would already know where to make the changes.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Now how would this translate into some hard code?
|
|
|
|
|
I haven't written anything like that. I just have a couple theories in my head about how I would approach the problem.
Storing the text seperate from the formatting gives you quick access to the formatting itself. Pointers between text segments and existing formatting objects in a collection would allow for reuse of the same formatting object to control the formatting of several segments of text.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Since quite sometime I am trying to figure out how to change backcolor of a particular column in datagridview.
CellPainting event does that but I do not want to use, is there any property available, which can be used easily?
Please suggest, Thanks in advance.
Thanks,
RajKat
|
|
|
|
|
In your column's DefaultCellStyle property, you can change the BackColor. For example:
' Somewhere in your code to setup your columns:
'
Dim newCol As New DataGridViewTextBoxColumn
With newCol
.DataPropertyName = "databaseTableColumnName"
.HeaderText = "My Column Header"
.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader
.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.DefaultCellStyle.BackColor = Color.Blue
End With
DataGridView1.Columns.Add(newCol)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hey Dave,
Thanks for the solution, I was really looking for it.
Can you also tell me how to change the backcolor of just one cell of a datagridview?
I do not know what the problem is but
datagridview.rows(0).cells(0).style.backcolor=color.gray
is not working for me.
If any alternative or solution is there then please let me know.
Thanks,
RajKat
|
|
|
|
|
That code should work fine, so long as the DGV is filled with data already.
RoundsGridView.Rows(0).Cells(0).Style.BackColor = Color.BurlyWood
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have 2 DataGridView and I need them to scroll together. The first DataGridView has Scrollbars set to none and the second DataGridView is only displaying the Vertical scrollbar. I need the Sync. the second DataGridView's vertical scrollbar to move the first DataGridView's vertical position.
Private Sub _Scrolling(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs)<br />
Dim g As DataGridView = CType(Me.MainTabControl.Controls.Find("Employee_times", True)(0), DataGridView)<br />
' need help tranfering the event to the first DataGridView<br />
End Sub
Thanks.
|
|
|
|
|
Well, there's an easy way and a hard way. We'll try the easy way first:
The easy way is to put both DGV's in a Panel control and turn scrolling on in the panel. Don't turn on scrolling in the DGV's and don't worry about how big they DGV get. Just let them grow as far as they want in the vertical direction. The panel will then take care of the scrolling for you.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How simple was that. LOL I ended up with a work around using the..
gTime.SetBounds(0, (-gEmployee.VerticalScrollingOffset) + 11, gTime.Size.Width, gTime.Size.Height)
Thanks for the help. I've been wanting to contribute to the site with an article of some sort. So, I'm thinking of using parts of my current project with the multiple datagridviews and runtime creation of them and linking. As my first attempt at an article on the site.
Thanks again.
|
|
|
|