|
I am trying to pass a Integer to my sql statement.
If I use this,
sComm += "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam FROM Fixtures WHERE (Fixtures.FixtureID = ID)"
It doesn't work.
But if I use this:
sComm += "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam FROM Fixtures WHERE (Fixtures.FixtureID = 1)"
It does work, obviously only getting fixture Id 1. The numbers I am trying to SELECT WHERE are autonums, could this be doing it.
|
|
|
|
|
Change the sql statement to this
Dim ID as integer = //source of id
sComm += "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam FROM Fixtures WHERE Fixtures.FixtureID = " & ID & ";"
|
|
|
|
|
You could go with KaptainKrunchs version but it's always better to use stored procedures and parameterized queries. Read SQL Injection Attacks and Some Tips on How to Prevent Them[^] by Colin Angus Mackay for more information.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In addition to what's already been said, why are you adding to sComm instead of just assigning a value to it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
try this
cmd = new oledb.oledbcommand
cmd.commandtext = "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam FROM Fixtures WHERE (Fixtures.FixtureID = ?)"
cmd.parameter.add("@1",1)
cmd.execute
its very safe
try this
V.Gopi.
Easy Design Systems
Coimbatore
India
|
|
|
|
|
Hi. My problem is this. I created a MS Access application in Access 2000 under Windows 2000, Service Pack 4.
My Access application has a form that asks the user to provide a file's pathname and I provide the Open/Save-As common dialog using MS Common Dialog Control, version 6.0. I do this using underlying VBA code and the properties of the Commond Dialog (OLE Class=CommonDialog, Class=MSComDlg.CommonDialog.1)
'call the Open file dialog and retrieve pathname selected<br />
'the Open/SaveAs common dialog appears as an ActiveX Control on the form (design view)<br />
<br />
With ActiveXCtl_OpenSaveAs<br />
.CancelError = True<br />
.Filter = "My data files (*.csv;*.txt)|*.csv;*.txt|All Files (*.*)|*.*"<br />
.DefaultExt = ".csv"<br />
.DialogTitle = "Select data file for Import"<br />
.FilterIndex = 1<br />
.Flags = cdlOFNHideReadOnly<br />
' .Filename = strInitialFilename<br />
.ShowOpen<br />
'<br />
If .Filename <> "" Then<br />
editInputPathname.Value = .Filename<br />
End If<br />
'<br />
End With<br />
Under Office 2003 on a Windows XP machine, I get the error
Microsoft Office Access
Object doesn't support this property or method
then related error messages...
You don't have the license required to use this Active X control...
I have tried putting the COMDLG32.OCX file in places it should find, but that doesn't help.
What must I do to get my code to work on latest Access edition?
Thanks.
Johnny
|
|
|
|
|
I got this message after executing a stored procedure under SQL server.
Procedure or function UpdateAllRecords has too many arguments specified.
the SQL code is:
CREATE PROCEDURE dbo.UpdateAllRecords
@form_id int,
@username varchar,
@site varchar,
@division varchar,
@branch varchar,
@activity varchar,
@room varchar,
@location varchar,
@hazard varchar,
@description varchar,
@rating varchar,
@probability varchar,
@level varchar,
@ventilation varchar,
@laboratory varchar,
@clothing varchar,
@gloves varchar,
@eye varchar,
@respirator varchar,
@footwear varchar,
@info varchar,
@person varchar,
@summary varchar,
@discussed varchar,
@project varchar,
@manager varchar
AS
UPDATE form
SET
activity = @activity,
room = @room,
location = @location,
hazard = @hazard,
description = @description,
risk = @rating,
probability = @probability,
levels = @level,
ventilation = @ventilation,
laboratory = @laboratory,
clothing = @clothing,
gloves = @gloves,
eye = @eye,
respirator = @respirator,
footwear = @footwear,
info = @info,
persons = @person,
summary = @summary,
discussed = @discussed,
lab_manager = @manager,
pro_manager = @project
WHERE
form_id = @form_id
GO
And the page code is:
conn.Open()
Try
Dim command As New SqlCommand("UpdateAllRecords", conn)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@form_id", Session("form_id"))
command.Parameters.Add("@username", Session("username"))
command.Parameters.Add("@site", Session("site"))
command.Parameters.Add("@division", Session("division"))
command.Parameters.Add("@branch", Session("branch"))
command.Parameters.Add("@activity", Session("activity"))
command.Parameters.Add("@room", Session("room"))
command.Parameters.Add("@location", Session("location"))
command.Parameters.Add("@hazard", Session("hazard"))
command.Parameters.Add("@description", Session("description"))
command.Parameters.Add("@rating", Session("rating"))
command.Parameters.Add("@probability", Session("probability"))
command.Parameters.Add("@level", Session("level"))
command.Parameters.Add("@ventilation", Session("ventilation"))
command.Parameters.Add("@laboratory", Session("laboratory"))
command.Parameters.Add("@clothing", Session("clothing"))
command.Parameters.Add("@gloves", Session("gloves"))
command.Parameters.Add("@eye", Session("eye"))
command.Parameters.Add("@respirator", Session("respirator"))
command.Parameters.Add("@footwear", Session("footwear"))
command.Parameters.Add("@info", Session("info"))
command.Parameters.Add("@person", cblPersons.SelectedItem.Text)
command.Parameters.Add("@summary", Session("summary"))
command.Parameters.Add("@discussed", rblOption.SelectedItem.Text)
command.Parameters.Add("@project", Session("project"))
command.Parameters.Add("@manager", Session("manager"))
command.Parameters.Add("@project", Session("project"))
command.ExecuteNonQuery().ToString()
Finally
conn.Close()
End Try
Can anyone please help?
I appreciate you taking your time.
|
|
|
|
|
You defined a project parameter twice.
mcgannmcgann wrote:
command.Parameters.Add("@project", Session("project"))
command.Parameters.Add("@manager", Session("manager"))
command.Parameters.Add("@project", Session("project"))
Also why put a .ToString() on the ExecuteNonQuery method if your not using the return value?
|
|
|
|
|
Can somebody tell me how to run my Windows Application with different Windows User credentials (Windows 2000 Or XP)
I have the UserName and Password which I want to hardcode
A restriced windows users uses this application and the application involves different operations which require a standard or admin user
Thank You
|
|
|
|
|
An application can't get security higher than the person who ran it.
In order for this to work, your application must be executed, from the very start, using different credentials.
This means either...
1) Holding down Shift while you right-click the icon for the app and clicking "Run As", then supplying the credentials.
2) Using the RunAs command line app to launch your application. but since the username and password would be plainly visible, this isn't the best option.
3) Writing your own launcher application that can launch your application using a username and password. You'll have to use the CreateProcessAsUser[^] Win32 API function to launch your application. The downside to this is how are you going to store the username and password so your launcher app can get to it? If your machines are in a workgroup environment, is this username and password the same on all machines? If so, you've got issues.
Now, noone of these options are the best one. Since the application will be running under a common account, you can't tell who's really doing what with that account. It's a generic that is difficult to administer, and that is a big security concern.
You'd be much better off expanding the rights of the people using the application than you would using the RunAs service.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello Dave!
Thank you for replying.
I think the 3rd option is the suitable one if I keep the encrypted username and password in the text file or registry
Do you?
|
|
|
|
|
Encrpyting it isn't the hard part. Get the CreateProcessAsUser part to work first.
After being a LAN Admin for many years, I'm still going to tell you that this is NOT the way to go.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a text box with the value "Hello There"
How do I get the following i.e. view there on the next line....
Hello
There
I remember in VB6 it was something like
txtLine.Text = "Hello" & Chr(13) & "There"
I must be something wrong, what is it.
Thanks in advance
|
|
|
|
|
Dim sArray() as string = Split(textbox1.text)
dim x as integer
for x = 0 to sArray.Length - 1
Debug.WriteLine(sArray(x))
Next
vbCrLf = Carriage Return
|
|
|
|
|
First, make sure that the TextBox MultiLine property is set to True.
If you want to put a CrLf in the middle of the string, you just do this:
Dim myText As String = "Hello" & Environment.NewLine & "there"
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I need help. I want to store values into this file and be able to retrieve the values later if the program starts again.
|
|
|
|
|
The App.Config file really isn't meant for that. It's meant to be, from the applications point of view anyway, a ReadOnly file. User configuration settings should normally be stored in their own file.
But since App.Config is just a standard XML file, you can use any XML methods to modify it. Just search the articles for "XML" and you'll find a bunch of examples.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello. I'm a beginner to VB.NET, and i'm sure the solution to my question is easily achieved, however...
I'm trying to have a list of items in a ComboBox. When the user clicks on an item in the combobox, there is a large textbox that I would like a few sentences to appear for each item. How would I go about doing that?
Any help is appreciated ^_^ Thanks.
|
|
|
|
|
Hi,
to add items to the combobox just use the items.add method:
combobox.items.add("Item to add")
to change the textbox catch the combobox selectedindex changed (or there maybe a click event as well) and then you have to choices, you can look ad the SelectedIndex property, carrying the index of the selected item or you can look at the Text property with the text of the item. Based on that with some if statements or a select case or even using the selectedindex for accessing an array you can update your textbox.
|
|
|
|
|
|
hey guys out there,god bless to all of you. hope you could help me on my problem. our consultant want us to export all of our datasets (came from sql 2000) into excel files using vb.net inorder for the user to manipulate what are the only data they need to print, it varies depend on what type of report it is.
thankz guyz.
hoping for your reply.
(",) KC...
|
|
|
|
|
|
thankz ashishbahrn for the help.
gonna try for it...
god bless...
(",) KC...
|
|
|
|
|
Hi everybody!!!
I' wrote a function on a Visual Basic 6 application that uses an instance of Excel application (it's a hidden instance and I disabled functions that may slow down such as screen update and calculation), I need to control Excel from this application to do some specific operations. The strange thing is that the same operations i run from from my application to control excel are about 10 times slower than running them from VBA (running the same function as an Excel Macro, saved with the workbook). How is it possible??? Is there something that I missed to check???
Thanks in any case. TK
TK
|
|
|
|
|
Let me see the part of your code that you are creating the Excel application and calling some of its operations. You might be accidentally creating a new instance of you Excel app each time you make a call, or, even worse, making multiple instance of Excel. Either way would make your VB app run slow; and, if the latter, increasingly slow.
|
|
|
|
|