|
hi all
i have a Procedure that return a row affected. its like this
Create Proc CheckExistance(@username varchar(50))
as
Select @@Rowcount from Login where Username = @username
And on my vb code its like this
Answer = cmd.ExecuteNonQuery()
PLease note that Answer is an integer variable, that i want to assign the value returned by a stored Procedure.
Forgive me about formatting issues, i have a problem with code project lately, buttons don't appear nicely, i cant even use pre, because it takes me to another page.
thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Vuyiswa wrote: Select @@Rowcount from Login where Username = @username
This doesn't look right. Getting the rowcount from a query in T-SQL requires a separate query.
IMHO, the most efficient way to check for the existence of a record is to use the EXISTS keyword. This is because SQL Server will stop searching as soon as it finds the first match. For instance:
IF EXISTS (SELECT TOP 1 * FROM Login WHERE Username = @username)
RETURN 1
ELSE
RETURN 0
END
BTW, not sure what problem you are having with <pre> tags. They're working OK for me.
Hope this helps.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
hi Paul
thanks for the reply, think you gave me what i needed thanks.
i think it was my connection and my browser, that wanted to move away from the page when i tried to Click "
" tag, next time i will type it , i was too lazy am sorry.
Thanks for the help
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hi friends
Currently i m working on msTAPI3.0 in vb.net. I want to call 3 customer so i user for loop. When loop play for first time the message sent successfully but second time an error occur error is:
------------------------------------------------------------------------
Uninitialized object (Exception from HRESULT: 0x80040007 (OLE_E_BLANK))
------------------------------------------------------------------------
How can i sort out this error. Plz solve my problem.
Thanks in advance
|
|
|
|
|
You need to the post a code snippet of what is throwing this error. Without seeing it, anyone who gives you an answer is just guessing at the problem.
|
|
|
|
|
He must be expecting someone to know the error code right off the top of their head?
I just take the whole error code and put it in a google search.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Like Dave said, you need to post the code snippet where you are having trouble. No one can really help without seeing it.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
my fra tab is designed for
activetablabelbackcolor is Teal &
inactivetablabelbackcolor is Gray.
let my fra tabs be two fra tabs.
firstly,fratab_1 is active and this backcolor is Teal
and fratab_2 is inactive,then i changed to fratab_2 ,
but fratab_1 is not completely inactive,a little active
Teal color is still at top of the tab_1 ,and fratab_2
is not completely active ,a little inactive Gray color
is include at top of the tab_2
|
|
|
|
|
|
thanks a lot for ur answer
|
|
|
|
|
Mate, if that is a question, it certainly makes no sense to me.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I thought the reply was pretty clear but I guess not so here goes.
Please restate your question.
If no one can understand it, no one can answer you.
|
|
|
|
|
I am trying to build my own SQL Query Analyzer to use with our DB2 servers.
I want to have a drop down list fill with all the available DB2 servers on the network.
Does anyone know how I can accomplish this. I figured out how to listen for SQL Servers but not DB2 servers.
Any help would be appreciated.
|
|
|
|
|
I have found alot online about how to add a control at runtime. Unfortunately, I haven't yet found anything that explains how to add multiple controls at once from one event.
I will post what I tried to use to add three textboxes. When I run it, only the third textbox is visible and I'm not entirely sure if the first two were created. (I'm thinking that they were created but replaced by the latest new textbox.) Anyway below is my code. Thanks to anyone who can see what I am doing wrong here:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim NewTB As New TextBox
Dim TBName As String
Dim TBindex As Integer = 1
For TBindex = 1 To 3
TBName = "Textbox" & TBindex
Me.Controls.Add(NewTB)
NewTB.Name = TBName
NewTB.Enabled = True
NewTB.Visible = True
NewTB.Height = 20
NewTB.Width = 100
NewTB.Top = 130 + ((TBindex - 1) * 25)
NewTB.Left = 20
Next TBindex
End Sub
"That rug really tied the room together."
|
|
|
|
|
You need to do your first line inside the loop. You created one textbox and added it three times. You need to create a new textbox to add every time.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks very much, Christian. That did the trick!
"That rug really tied the room together."
|
|
|
|
|
each textbox has to have it's own instance
Dim NewTB As TextBox
Dim TBName As String
Dim TBindex As Integer = 1
For TBindex = 1 To 3
NewTB = New TextBox 'this belongs here
TBName = "Textbox" & TBindex
NewTB.Name = TBName
Me.Controls.Add(NewTB)
NewTB.Enabled = True
NewTB.Visible = True
NewTB.Height = 20
NewTB.Width = 100
NewTB.Top = 130 + ((TBindex - 1) * 25)
NewTB.Left = 20
NewTB = Nothing
Next TBindex
|
|
|
|
|
Problem:
Currently I have 12 Excel workbooks (each with 7 worksheets).
The data is identical in nature. The common part is the VBA code.
Every time I have to make a change to one of the worksheet's VBA code,
I need to copy the changes to the other workbooks.
I can use either the Excel buit-in VB editor, or any flavor of Visual
Studio.
I would like to be able to make the modification only once and have
the workbooks reference the code instead of copying and pasting to
each workbook.
Question(s):
1. Is there a way that I can have one central location for the VBA code?
2. Would an Excel add-in be appropriate?
3. Should I program using VS (VSTO)?
I am open to any approach to this problem.
Michael
If we knew what it was we were doing, it would not be called research, would it? --Albert Einstein
modified on Friday, December 07, 2007 3:25:20 PM
|
|
|
|
|
VBA doesn't include any "include" support. It can't import code from some other source. The code is part of the workbook itself.
I think you're taking the wrong approach. If the code needs to work with data from other files, it's the data that needs to be brought to the code, not the code to the data. Your code should be in one spot, and have the ability to use data from any workbook that you chose.
redjoy wrote: 1. Is there a way that I can have one central location for the VBA code?
Not in an external file, no. But, you can have an single workbook that can import data from other workbooks. Or, you can write the code as an Add-In to Excel.
redjoy wrote: 2. Would an Excel add-in be appropriate?
That depends on what your code is doing and what your business process dictates.
redjoy wrote: 3. Should I program using VS (VSTO)?
Probably. Do the research on VSTO here[^].
|
|
|
|
|
First of all thanks for your reply. I am new to add-ins and VSTO.
I only wrote the code behind the worksheets for my personal testing needs but my boss saw this and wants everyone to use this format. Hence the 15+ extra workbooks. I am now trying to re-write my code more efficiently (on my own time) as to make maintenance easier on me (and hopefully my test successors).
Dave Kreskowiak wrote: I think you're taking the wrong approach. If the code needs to work with data from other files, it's the data that needs to be brought to the code, not the code to the data. Your code should be in one spot, and have the ability to use data from any workbook that you chose.
The code does not need to work with data from other files. All the data needed is already contained within each workbook.
Dave Kreskowiak wrote:
redjoy wrote:
2. Would an Excel add-in be appropriate?
That depends on what your code is doing and what your business process dictates.
The format of each Workbook is the same. The code for each workbook is identical.
I use my workbook for analysis purpose and generate a report for each of my workbooks (CSCI).
I execute some code based of values in various columns for each row in worksheet 7.
unique to each workbook:
Columns A-D are used for showing my requirements, test cases and test conditions.
The same in each workbook:
Columns E and F are used to show the status of completeness and performance of current requirement.
Column G shows the platform the current test case runs on (A, B, Both).
Columns H and I shows the test result (P, F, N/A) for platform A chosen in G.
Columns J and K shows the test result (P, F, N/A) for platform B chosen in G.
Columns I-P: not important to code.
Code behind Worksheet 7
for example (pseudo code):
Sub Worksheet_Changed(target as range) 'changes the color coding of active row based on columns E through K.
if a2<>""then
if e2="Complete" and f3="Met" then set the background colors of a2:p2 to GREEN.
...code for color RED.
...code for color YELLOW.
else color WHITE.
end if
else
if g3 = "A" and h3="P" and i3="P" then set the background colors of b3:i3 to GREEN.
... code for color RED.
else color WHITE.
end if
end if
Code behind worksheet 8 copies portions of worksheet 7 to worksheet 2 and 6 and updates a database with the content of worksheet 7.
So right now when I improve/modify one workbook, I must copy the code to the other workbooks.
I was not able to find out any thing about add-ins using the VBA behind a worksheet. However, I will explore the websites you mentioned in your reply.
I hope this post makes sense.
Michael
If we knew what it was we were doing, it would not be called research, would it? --Albert Einstein
|
|
|
|
|
redjoy wrote: The code does not need to work with data from other files. All the data needed is already contained within each workbook.
...
The format of each Workbook is the same. The code for each workbook is identical.
You're missing the point. The code (all 15 copies of it) DOES work with the data from every workbook. You're trying to avoid maintaining 15 copies of the code, so you need to have only a single copy of it somewhere. That single copy needs to get at the data for all 15 workbooks.
But, as you post some of the code, you have a problem. You're handling the events fired by changes in the worksheet. This makes it very difficult to seperate the code from the data, and hence keep only a single copy of the code outside of the workbooks.
redjoy wrote: I was not able to find out any thing about add-ins using the VBA behind a worksheet.
That's because you can't. An Add-In is written in C++, C#, VB.NET, or something else that generates "real code" and is completely seperate from any workbooks.
I'd say your best bet is to write this as an Add-In to Excel.
|
|
|
|
|
I have my VBA script code in one XL file and then refer this file, from the file with the data.
If you clear the data sheets leaving only one (empty sheet) and saves this file as say MyCode.xls
Then open the VBA editor for this file, and goto project Explorer. rightclick on the the spreadsheet file, and choose properties.
That should enable you to give you code a specific name, its practical if it could start with 'a'.
If you then also open the spreadsheet containing only the data, again open the VBA editor, and in the project explorer select the data spreadsheet. Then goto "tools" and "references". This opens the ref's dialog. Here you should be able to locate your code among the many lines. (If the name of your code starts with 'a' it should sort to the top Check the box.
That should make your code freely available from the datasheet.
I use this approach from excel 2003, and the only downside I have found is that the references have absolute paths.
Regrads *Henrik
|
|
|
|
|
Hi every one..
I have a VB 2005 application and I am doing error handling by “on error goto”.
I wanted to create a log file if there is any error..
I have done some work in C and linux and wondering if there is any way that I can just echo a string to a text log file the way we are able to do in c by just using ‘>’ or some thing similar so that I do not have to open and close the target file each time…
Regards
Nishkarsh
|
|
|
|
|
you should look at try/catch vs on error goto
Private Sub LogMessageToLocalFile(ByVal sMessage As String)
Try
Dim oFile As New System.IO.StreamWriter("c:\myapperrors.log", True)
oFile.WriteLine(sMessage)
oFile.Flush()
oFile.Close()
oFile = Nothing
Catch
End Try
End Sub
|
|
|
|
|
Don't use on error goto. Use structured exception handling.
And have a google for "log4net" - its a free library for logging, and its excellent.
|
|
|
|