|
Either way, you'd do better to use parameterised queries or, better yet, stored procs.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
"'to_char(UTime,'dd-mon-yyyy')'"
Are the first and last ' in this correct ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
you know if we write our insert statement by putting a static Date like:
q = "insert into user_proj_trans(user_index,proj_code,proj_trns,user_expired_time) " & _
" values(" & UIndex & "," & PC & "," & PT & "," & "'30-dec-2007'" & ")"
the last statement will be correct and I tried it.
but I need to read the date from the screen using the variable UTime which is the value reurned by selecting from a DateTimePicker object....So I need to convert the UTime value into the correct format that is like:
"'30-dec-2007'"
and I tried that using to_char function but it did not work
|
|
|
|
|
The comma is missing after the string 'to_char(UTime,' . As you have apostrophes inside the string, the string ends at the first apostrophe.
I imagine that you don't want to put the literal string "to_char(UTime,'dd-mon-yyyy')" in the user_expired_time field, but rather that the function to_char should be used to create a date value for the field. Then you should not put the function call inside a string, but concatenate the return value of the function with the other strings.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
u can use parameteraized Query like:
dim cmd as new sqlcommand
cmd.commandtext="insert into user_proj_trans(user_index,proj_code,proj_trns,user_expired_time) values (@user_index,@proj_code,@proj_trns,@user_expired_time)"
cmd.parameters.add(@user_index,UIndex)
cmd.parameters.add(@proj_code,PC )
cmd.parameters.add(@proj_trns,PT )
cmd.parameters.add(@user_expired_time,UTime)
cmd.connection.open
cmd.executenonquery
cmd.connection.close
this is maybe better than u had wrote ,
Mohamad A. Flefel
mflefel@hotmail.com
+962 79 5963865
C#.net & VB.net Developer
|
|
|
|
|
I think your query should read:
q = "insert into user_proj_trans(user_index,proj_code,proj_trns,user_expired_time) " & _
" values(" & UIndex & "," & PC & "," & PT & ",'" & to_char(UTime,"dd-mon-yyyy") & "')"
|
|
|
|
|
Hi gyes,
I realy tried all of your advices, but no one has solved the problem. and finalla I think there is another problem which is represented in an Oracle problem which is:ORA-00932: inconsistent datatypes: expected Date got number
we need to know whats the function that converts the String or the Character into a Data datatype to stored correctly in the DataBase.
there is a function called "Convert" which may help but also it did not work
please any body has an idea to solve the problem, I will be very appreciative
kind regards
|
|
|
|
|
Hi all,
I have a sorted, non-editable DataGridView which contains some cells in each row that are traffic-lighted (ie: they have a different b/g colour depending on value) but when I populate the control the row that was the first one (before sorting) is always highlighted thus wiping out my custom coloured cells. I have tried every combo of colours and highlighting options to try and stop the DGV doing this but can't find a way. Ideally I just want to suppress altogether the DGV control selecting a row when it populates - does anyone know how I can go about this?
This is driving me mad so I hope someone can help!
TIA...
Mike
|
|
|
|
|
There should be an option where readonly means "for use as display only no selection please".
I got this effect in a recent project by deselecting everything just after the DataGridView was populated.
The Deslection:
Private Sub DeselectGridRows(ByVal dgv As DataGridView)
Dim dgr As DataGridViewRow
For Each dgr In dgv.SelectedRows
dgr.Selected = False
Next
End Sub
Deselecting called form within the forms load event:
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Windows.Forms.Cursor.Current = Cursors.WaitCursor
Me.SuspendLayout()
PopulateDataGridView(dgv)
DeselectGridRows(dgv)
Me.ResumeLayout()
Windows.Forms.Cursor.Current = Cursors.Default
End If
End Sub
|
|
|
|
|
Thanks Leah.... actually I'm not sure why I even posted the question as I realised soon after all you need to do is say datagridview1.SelectedRows(0).Selected = false and that takes care of it.
What I want to do now is only highlight a row when the user clicks on one but rather than using a background colour (which obscures my cell traffic-lighting) I want to leave the B/G and F/G colours as they are and instead draw a 2-pixel red border around the entire row - and I'm thinking the only way to do that is to override one of the Paint methods... anyone know of a better/simpler way?
|
|
|
|
|
This is proably an old thread now and past it's sell by date, but I did put an article in about drawing cell colours that may or may not help. Search the articles for 'Couluring and centering cells in datagridview' - Yes it contains a typo that got uploaded to the web!
David Loring
!! Keep Music Live !!
|
|
|
|
|
I'm sure it's been covered by many articles, but i'd like some direct help. I'm trying to write a simple Database program with a few fields, an autoincrement customer number etc. I used the easy vs way to develop my form, i built a database, connected it to my program then dragged and dropped the details version of my customers data table, it went ahead and created its navigation bar and what-not.
All sounds good so far, except when i run it. When I run the program, add, edit and then click save data, nothing happens, i mean it thinks for a moment, but when i shutdown the program and restart, all the data i changed or created has just disappeared. Has anyone had similar problem or can anyone suggest solution or even run me through how you would design a database driven program.
I am using Visual Studio 2005 and SQL Server 2005, database is customers.mdf
Thanks in advance.
Posted by The ANZAC
|
|
|
|
|
If you post some of your code, especially the onClick event of the save button on you navigation bar.
|
|
|
|
|
Well i'm not exactly sure what code to use, i mean it's all supposed to be automatic form designer generated isn't it? I have no code for the add button on the navigation bar, yet it's functional in runtime. Save, however i have code for:
Private Sub Customer_InformationBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)<br />
Me.Validate()<br />
Me.Customer_InformationBindingSource.EndEdit()<br />
Me.Customer_InformationTableAdapter.Update(Me.CustomersDataSet.Customer_Information)<br />
End Sub
Is this right, do i need to add anything more?
Posted by The ANZAC
|
|
|
|
|
your code is correct. I'm not sure why your not seeing your updated data within the database. When you make changes to the data while using your application, can you open the database and see your application changing the data. I work with ADO.NET all the time and eveything you've discribed is correct, best I could do is look at the application and walk it from point A to B with the debugger.
|
|
|
|
|
I just don't know, maybe it's a problem with my installation. How do i veiw the database as the application runs to see if it's working.
Posted by The ANZAC
|
|
|
|
|
|
i have vs 2005 should that not have it?
Posted by The ANZAC
|
|
|
|
|
Hey guys,
I just read abt the Image Element, i realised that once user click the image, the form will b submitted.
The question is, is it possible for me the implement the 'Image Element' for the image which i declare using the bitmap class?
I.e Dim b as new Bitmap("c:\image.jpg")
|
|
|
|
|
"Image Element"? What are you talking about? And what do you mean by "once user click the image, the form will b submitted"? Are you talking about an ASP.NET app or a Windows Forms App?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hey im sorry abt the confusion.
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/input_image.asp
Im refering to an ASP.NET app
|
|
|
|
|
What are you trying to do with this?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I wanna add control to the image, so that once the user click on certain location of the image, it will show differnet things.
|
|
|
|
|
You'd be better off asking this in the ASP.NET forum.
OK. This is going to get complicated. Take a look at this[^] article here on CodeProject. Basically, you are supplying a seperate URL for the source of the image, which will generate the new image and return it in the Response.OutputStream object. You can also find out more about the process here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Please don't cross post.
---
b { font-weight: normal; }
|
|
|
|