|
That will work a treat,
Its very similar to what i use in a standered VB6 application, just didnt think it would work on this for some reason. Thats the great thing about this site, theres always something more to learn
Thanks again
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
AreJay,
seems like ive hit a small problem, what happens if the stored proc returns a integer , ie in the stored procedure its returning an int as an output parameter;
in the stopred proc @ReturnValue INT OUTPUT
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Pete Newman wrote: @ReturnValue INT OUTPUT
table = New DataTable<br />
adapter.Fill(table)<br />
If CInt(table.Rows(0)(0)) <> 1 Then
The output is being returned into the datatable then tested with table.Rows(0)(0). I understand that the stored proc may have a param of @ReturnValue INT OUTPUT, is this stopping the proc from running because your not assigning an output variable? I don't use an output param with my stored procs, I'll need to test the code I've posted and get back to you.
|
|
|
|
|
cheers AreJay
i know there has to be a way... but well its beyond me
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Hi,
I have some problems with:
Dim oType As System.Type = oDAOModel.GetType
Dim oPropertyInfo As Reflection.PropertyInfo = oType.GetProperty("connected")
Dim oObjectAux As Object = oPropertyInfo.GetValue(oDAOModel, Nothing)
When the propety connected (Boolean type) is nothing, "If oObjectAux is Nothing Then" says that oObjectAux not is nothing, but "If CType(oObjectAux, Boolean) is Nothing Then" works fine.
How I can check if properties are Nothing dinamically (without knowing property type)?
Thanks,
Mario
|
|
|
|
|
I can't understand what you're trying to do with this...
But, if your cast an Object to a value type, is will never be Nothing. I don't get what you're trying to do with this???
amapumu wrote: How I can check if properties are Nothing dinamically (without knowing property type)?
You can't. Value types are never Nothing.
What is this code supposed to be doing? Why are you doing it this way?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm trying to know, using reflection, what properties of any object contains a Nothing value.
I want to obtain a message like:
"Object X, Property prop1 is Nothing, Property Prop2 not is Nothing..."
"Object Y, Property AnyProp1 is Nothing, Property AnyProp2 not is Nothing..."
....
|
|
|
|
|
Connected will return True or False, never Nothing. "Nothing" is not a value. It's a reference, or the lack of a reference to an object. Nothing means "this variable doesn't point to an instance of anything". So,
When the propety "connected" (Boolean type) is nothing...
will NEVER happen. Value types, like Integers and Booleans, will ALWAYS return a value, not a reference.
This is something I whipped up real quick. It's got some serious limitations and drawbacks, but it should give you the idea:
Private Function IsNull(ByRef obj As Object, ByVal prop As String) As Boolean
Dim memberInfos() As MemberInfo = obj.GetType().GetMember(prop, BindingFlags.Instance Or BindingFlags.Public)
If memberInfos.Length > 0 Then
For Each mi As MemberInfo In memberInfos
Debug.WriteLine(String.Format("Object Declaring Type: {0}", mi.DeclaringType.ToString()))
Debug.WriteLine(String.Format("Object Reflected Type: {0}", mi.ReflectedType.ToString()))
Debug.WriteLine(String.Format(" {0} is a {1}", mi.Name, mi.MemberType.ToString()))
Select Case mi.MemberType
Case MemberTypes.Property
Dim pi As PropertyInfo = obj.GetType().GetProperty(prop)
Dim v As Object = Nothing
v = pi.GetValue(obj, Nothing)
Debug.WriteLine(String.Format(" Value: {0} ({1})", v, pi.PropertyType().ToString()))
If v Is Nothing Then
Return True
Else
Return False
End If
End Select
Next
Else
Throw New InvalidArgumentException("Property name not found!")
End If
End Function
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I'd like to know how to save an image from a picturebox to a file. In Visual Basic 6 there was a very simple option: image.save(Filename, extension) or something like that but how can i save an image in VB.NET?
Thanks, Zaegra
--Zaegra--
|
|
|
|
|
This will only work depending on how you've drawn your image, but....
PictureBox1.Image.Save(filepath)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Jups that worked thanks Dave
--Zaegra--
|
|
|
|
|
Hi this is Tracy here.
I'm doing a form created from Visual Studio 2005 which contain a "Add" button and a DataGridView. If the records are successfully added, it will be inserted into the SQL server database. I am trying to insert records into my SQL Server database without retrieving any information first.
But my program can't work and I don't know where it had gone wrong.
Here listed my codes when the user click on the "Add" button for the DataGridView:
'Add Button For DataGridView
Dim sqlcom As SqlCommand = New SqlCommand()
Dim mySqlDataAdapter As SqlDataAdapter
mySqlDataAdapter = New SqlDataAdapter
Dim myDataSet AsNew DataSet()
Dim mySqlcb As SqlCommandBuilder
mySqlcb = New SqlCommandBuilder(mySqlDataAdapter)
mySqlDataAdapter.InsertCommand = mySqlcb.GetInsertCommand
mySqlDataAdapter.Update("TBReqDG") 'ERROR COMES FROM HERE
'Open connection, execute the commands
sqlcon.Open()
'Close Connection
sqlcon.Close()
But there is still an error as shown below:
Error 1 Overload resolution failed because no accessible 'Update' can be called with these arguments:
'Public Function Update(dataTable As System.Data.DataTable) As Integer': Value of type 'String' cannot be converted to 'System.Data.DataTable'.
'Public Function Update(dataRows() As System.Data.DataRow) As Integer': Value of type 'String' cannot be converted to '1-dimensional array of System.Data.DataRow'.
'Public Overrides Function Update(dataSet As System.Data.DataSet) As Integer': Value of type 'String' cannot be converted to 'System.Data.DataSet'. C:\Documents and Settings\Administrator\Desktop\CCC\OfasERP_New PartII\OfasERP\frmRequisitionVoucher.vb 246 9 OfasERP
Hope to receive reply soon as it's urgent & thanks
Regards
Tracy
|
|
|
|
|
It doesn't work because you haven't created a usable SqlDataAdapter. When you create one of these, you have to give it, at the very least, the Select command used to retrieve records out of your database. The SqlCommandBuilder then uses that SELECT query to build a matched UPDATE, INSERT, and DELETE query. When you called GetInsertCommand, nothing happened because there was no information usuable to build the INSERT query. Give it a SELECT command before you call anything on the SqlCommandBuilder object.
Dim conn As New SqlConnection(connectionString)
Dim da As New SqlDataAdapter("SELECT RecId, Name, Address FROM Customers", conn)
Dim cb As New SqlCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand()
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave and Everyone
I had done my sqlconnection in the public area.
I am trying to insert records from DataGridView into my SQL Server database without retrieving any information and I do not require to retrieve records from database. Initally, the database in SQL Server is empty. For this program, I made use of the SqlDataAdapter, DataSet and BindingSource.
This is my latest codings as listed below:
Dim sqlcom As SqlCommand = New SqlCommand()
Dim da As New SqlDataAdapter("SELECT * FROM TBReqDG", sqlcon)
Dim myDataSet As New DataSet()
Dim cb As New SqlCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand()
da.Update(myDataSet, "TBReqDG")'ERROR COMES FROM HERE
'Open connection, execute the commands
sqlcon.Open()
sqlcom.Connection = sqlcon
'Close Connection
sqlcon.Close()
As my program runs, it show this error Update unable to find TableMapping['TBReqDG'] or DataTable 'TBReqDG'.
Is this line really necessary or I just only have to declare the sqldataadapter ?
-->Dim da As New SqlDataAdapter("SELECT * FROM TBReqDG", sqlcon)
I don't know where it had gone wrong and hope anyone who knows is able to guide me along.
Hope to receive reply soon as it’s urgent & thanks.
Rgds
Tracy
|
|
|
|
|
Hi everybody here,
I want to know ur preferences for 1 thing that I really likeee so muuch - GDI+ or Graphics in VB.Net.
- Which is best book about GDI+ in VB.Net ???
I really appreciate ur help ...
|
|
|
|
|
|
Kulazfuk this forum isn't meant for such stupid answers, please respond normal or just say nothing.
|
|
|
|
|
Zaegra wrote: this forum isn't meant for such stupid answers
Nor is it meant for such stupid questions.
|
|
|
|
|
You we're saying something about "stupid answers"... You might want to check your own before judging someone elses.
And it is rude to yell like the OP did. The font size and bold was a bit over the top.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hmmm... not wanting to start an argument here but how many of my "stupid" answers have you had to correct? None that I can recall.
No need to get personal.
|
|
|
|
|
One, as of now. I never said I needed to correct any of your answers.
Or did yout just replay to the wrong person?? Maybe you were looking to reply to Zaegra??
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Oops! Sorry Dave! I got it all arse about face. Deepest apologies - I read your reply last night, thought you were having a go at me & got even more defensive.
Once again my apologies & thanks for pointing this out. Not sure if you're a drinking man but here, have a
Mental note 46 394 571 984: Read CP posts more objectively.
|
|
|
|
|
Hey .... have u get any illness,,,,
I am ask xperts not ... stupids/////
great job ...kulazfuk hahhaha LoL voilaaa
|
|
|
|
|
b3t1m0s wrote: I am ask xperts not
After posting a grand total of 3 posts, none of which are providing advice from your extensive experience, I seriously doubt you have any idea of what an expert is.
idiot alert...
|
|
|
|
|