|
I have a suggestion that u might wanna look at,
what you can do is to highlight those records that caused the problems and let user rectify.
BTW : I am curious, how can u let user update fields that can cause DB error? wanna leave an example here?
thx
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
|
|
|
|
|
You're thinking along the same lines as me. However, the question is, how does one determine which records are the rogues? For example, if we are sending 5 records back to the datasource but one has caused a concurrency violation, how do we know which one has caused the violation?
As for your question I think it's just a case of highlighting the field (on the data-entry form) that caused the error, allowing the user to correct the data, then allowing them to save the data again (via the appropriate command button on your form).
Rommel the iCeMAn,
Computer Programmer,
Barbados, West Indies.
|
|
|
|
|
Hi our company looking for a custom report generator where user can pick which columns to view on the report. Also they should able to resize the columsn to fit their need like PeachTree reporting.
|
|
|
|
|
I know there are a lot of sample for creating office addins or addins for microsoft product. Is there any sample to do the same thing for photoshop or other application?
Shinay
|
|
|
|
|
I am trying to add a column in a datagrid that I set up and I got that to work, but the problem I am having is trying to get Access to update and keep the new column on file. I am using Visual Studio .Net and am trying to get this to work in Visual Basic.
Bobby
underb@d20.co.edu
|
|
|
|
|
I just received a call to debug a TAPI problem.
The company that created the control no longer exists.
Problem: When the VB App finished making a call and downloading via modem, it closes the program without giving a reason. This only occurs on machines running Win2000 or WinXP. The program was origanaly written and tested on Win2000 (also tested on Win3.1, Win95 and Win98).
Could this have something to do with Windows security updates?
Any ideas would be helpfull.
INTP
|
|
|
|
|
Hi there,
I'm trying to create a DAL. Therefore I'm analyzing the DotNetNuke project and extracting code to create my own DAL. Thusfar I managed to talk to the database (with DataProvider.Instance). Now I'm trying to use a FillObject method, but I seem to be stuck at this point. I'm getting the following error 'System.Reflection.TargetException: Object does not match target type'. The error occurs in the sub CreateObject (last catch) at the following line 'CType(objProperties(intProperty), PropertyInfo).SetValue(objObject, Null.SetNull(CType(objProperties(intProperty), PropertyInfo)), Nothing)'. I was trying to isolate the problem (in sub Testing), but I can't figure out what's going wrong. I'm new to this stuff (that is working with a DAL, filling objects automatically) and I'm not an DotNet expert. Could someone explain to me what's going wrong? Does it have anything to do with trying to fill a wrong instance? Here's my code:
Imports DB
Imports DB.Data
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Collections.Specialized
Imports System.Configuration
Imports System.Data
Imports System.Data.OleDb
Imports System.Reflection
Imports System.Web
Imports System.Web.Mail
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Xml
Namespace Message
Public Class Contact : Inherits Page
Public lblStatus As Label
Public dg1 As DataGrid
Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim msg As New MessageController
Dim messageid As Integer = 52
dg1.DataSource = DataProvider.Instance.GetMessage(messageid)
dg1.DataBind
Dim m As MessageInfo = CType(FillObject2(DataProvider.Instance().GetMessage(messageID), GetType(MessageInfo)), MessageInfo)
'lblStatus.Text = "test" & m.Content
' Testing(GetType(MessageInfo))
End Sub
Public Sub Testing(ByVal objType As Type)
Dim objObject As Object = Activator.CreateInstance(objType)
Dim intProperty As Integer = 4
Dim objProperties As ArrayList = GetPropertyInfo2(objType)
Dim bla As System.String = "bla"
Dim pType As Type = CType(objProperties(intProperty), PropertyInfo).PropertyType
'Mypropertyinfo.SetValue(objObject, bla, Nothing)
'CType(objProperties(intProperty), PropertyInfo).SetValue(objObject, Convert.ChangeType("hallo", pType), Nothing)
Dim MypropertyInfo As PropertyInfo = CType(objProperties(intProperty), PropertyInfo)
Response.Write(" GetValue: " & MypropertyInfo.GetValue(objObject, Nothing).ToString())
' Mypropertyinfo.SetValue(objObject, "This caption has been changed.", Nothing)
' Response.Write(" GetValue: " & Mypropertyinfo.GetValue(Myproperty, Nothing).ToString())
Response.Write(MypropertyInfo.ToString)
End Sub
Public Sub PrintValues(myList As IEnumerable)
Dim myEnumerator As System.Collections.IEnumerator = myList.GetEnumerator()
While myEnumerator.MoveNext()
Response.Write(myEnumerator.Current.ToString & " ")
End While
End Sub
Public Function FillObject2(ByVal dr As IDataReader, ByVal objType As Type) As Object
Dim objFillObject As Object
Dim intProperty As Integer
' get properties for type
Dim objProperties As ArrayList = GetPropertyInfo2(objType)
' get ordinal positions in datareader
Dim arrOrdinals As Integer() = GetOrdinals2(objProperties, dr)
PrintValues(objProperties)
For i As Integer = 0 To arrOrdinals.GetUpperBound(0)
Response.Write(arrOrdinals(i) & " ")
Next
' read datareader
If dr.Read Then
' fill business object
objFillObject = CreateObject2(objType, dr, objProperties, arrOrdinals)
Else
objFillObject = Nothing
End If
' close datareader
If Not dr Is Nothing Then
dr.Close()
End If
Return objFillObject
End Function
Public Function GetPropertyInfo2(ByVal objType As Type) As ArrayList
' Use the cache because the reflection used later is expensive
Dim objProperties As ArrayList = CType(DataCache.GetCache(objType.FullName), ArrayList)
If objProperties Is Nothing Then
objProperties = New ArrayList
Dim objProperty As PropertyInfo
For Each objProperty In objType.GetProperties()
objProperties.Add(objProperty)
Next
DataCache.SetCache(objType.FullName, objProperties)
End If
Return objProperties
End Function
Private Function GetOrdinals2(ByVal objProperties As ArrayList, ByVal dr As IDataReader) As Integer()
Dim arrOrdinals(objProperties.Count) As Integer
Dim intProperty As Integer
If Not dr Is Nothing Then
For intProperty = 0 To objProperties.Count - 1
arrOrdinals(intProperty) = -1
Try
arrOrdinals(intProperty) = dr.GetOrdinal(CType(objProperties(intProperty), PropertyInfo).Name)
Catch
' property does not exist in datareader
End Try
Next intProperty
End If
Return arrOrdinals
End Function
Private Function CreateObject2(ByVal objType As Type, ByVal dr As IDataReader, ByVal objProperties As ArrayList, ByVal arrOrdinals As Integer()) As Object
Dim objObject As Object = Activator.CreateInstance(objType)
Dim intProperty As Integer
' fill object with values from datareader
For intProperty = 0 To objProperties.Count - 1
If CType(objProperties(intProperty), PropertyInfo).CanWrite Then
If arrOrdinals(intProperty) <> -1 Then
If IsDBNull(dr.GetValue(arrOrdinals(intProperty))) Then
' translate Null value
CType(objProperties(intProperty), PropertyInfo).SetValue(objObject, Null.SetNull(CType(objProperties(intProperty), PropertyInfo)), Nothing)
Else
Try
' try implicit conversion first
CType(objProperties(intProperty), PropertyInfo).SetValue(objObject, dr.GetValue(arrOrdinals(intProperty)), Nothing)
Catch ' data types do not match
Try
Dim pType As Type = CType(objProperties(intProperty), PropertyInfo).PropertyType
'need to handle enumeration conversions differently than other base types
If pType.BaseType.Equals(GetType(System.Enum)) Then
CType(objProperties(intProperty), PropertyInfo).SetValue(objObject, System.Enum.ToObject(pType, dr.GetValue(arrOrdinals(intProperty))), Nothing)
Else
' try explicit conversion
CType(objProperties(intProperty), PropertyInfo).SetValue(objObject, Convert.ChangeType(dr.GetValue(arrOrdinals(intProperty)), pType), Nothing)
' Response.Write(pType.ToString & " " & objObject.ToString)
' Response.Write(" " & Convert.ChangeType(dr.GetValue(arrOrdinals(intProperty)), pType).ToString & "")
End If
Catch
' error assigning a datareader value to a property
CType(objProperties(intProperty), PropertyInfo).SetValue(objObject, Null.SetNull(CType(objProperties(intProperty), PropertyInfo)), Nothing)
End Try
End Try
End If
Else ' property does not exist in datareader
CType(objProperties(intProperty), PropertyInfo).SetValue(objObject, Null.SetNull(CType(objProperties(intProperty), PropertyInfo)), Nothing)
End If
End If
Next intProperty
Return objObject
End Function
End Class 'Contact
Public Class MessageInfo
'local property declarations
Private _ID As Integer
Private _UserID As Integer
Private _CreatedDate As Date
Private _Category As String
Private _Subject As String = "test"
Private _Content As String
'initialization
Public Sub New()
End Sub
'public properties
Public Property ID() As Integer
Get
Return _ID
End Get
Set(ByVal Value As Integer)
_ID = Value
End Set
End Property
Public Property UserID() As Integer
Get
Return _UserID
End Get
Set(ByVal Value As Integer)
_UserID = Value
End Set
End Property
Public Property CreatedDate() As Date
Get
Return _CreatedDate
End Get
Set(ByVal Value As Date)
_CreatedDate = Value
End Set
End Property
Public Property Category() As String
Get
Return _Category
End Get
Set(ByVal Value As String)
_Category = Value
End Set
End Property
Public Property Subject() As String
Get
Return _Subject
End Get
Set(ByVal Value As String)
_Subject = Value
End Set
End Property
Public Property Content() As String
Get
Return _Content
End Get
Set(ByVal Value As String)
_Content = Value
End Set
End Property
End Class 'MessageInfo
Public Class MessageController
Public Function GetMessage(ByVal messageID As Integer ) As MessageInfo
Return CType(CBO.FillObject(DataProvider.Instance().GetMessage(messageID), GetType(MessageInfo)), MessageInfo)
End Function
End Class 'MessageController
End Namespace
|
|
|
|
|
My VB6 program can't find referenced dll unless it located under windows directory.
What should I do in order that my VB app will search for referenced dll in local directory first?
|
|
|
|
|
Can you post the way you use the dlls?
Because when referencing a dll, OS first looks in the SAME directory that your application is running, then looks in the system folders.
|
|
|
|
|
I'm using the dll by point on its *.tlb file location via the "reference" dialog box (I have created the dll with *.odl and *.def files).
|
|
|
|
|
Hey,
I am developing a VB.NET application and am required to write a help guide to go with it.
I am using Microsofts HTML Help Workshop which is proving a vague program to use.
Is there any suggestions that you have for creating a help file and incorporating it into the applciation?
How do you create help files? What software do you use?
Thanks for your help
Chris
|
|
|
|
|
I agree Chris,
MS HTML Help is a pain to use. I've switched to RoboHelp (www.robohelp.com[^]), haven't looked back since. It's NOT free tho
Hope this helps
Rommel the iCeMAn,
Computer Programmer,
Barbados, West Indies.
|
|
|
|
|
Hello there,
I am trying to get the thumbnail preview of a file to display in an image control when you click on a file, like you see in Explorer. I know not all files support this, and that's ok.
After doing some googleing I found that IExtractImage is the way to go, but I can't find any vb.net code. It's all in c++ or vb6, and when I try to convert the vb6 code, I get a lot of errors/warnings that I can't seem to fix.
If anyone has any ideas of how to go about this, it would be greatly apreciated.
Thank you.
using:
XP
VS 2003
Will
|
|
|
|
|
How can I open the PrintDialog in a WEB form?
I have a crystalreport that I want to send directly(not to pdf, etc.) to a printer on the clients local machine. I've found a way to display available printers(System.Drawing.Printing.PrinterSettings.InstalledPrinters), but it only displays printers on the server, not local.
Thank you for any help!
|
|
|
|
|
First, your question belongs in the ASP.NET Forum.
Second, you can't do it using ASP.NET. ASP.NET only generates HTML that the browser can display. It has absolutely no control over the client. You'll have to come up with a JavaScript solution that the client can run itself.
No, don't ask me for an example because I don't have one.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a function in a VC Dll that has arguments which are LPCTSTR.
I am trying to call the function in VB, but I'm having problems.
I declared the function in VB as follows:
Private Declare Function function_name Lib "dll_name" _
(ByVal arg1 As String, ByVal arg2 As String) _
As Boolean
Both arg1 and arg2 are LPCTSTR.
Does anyone know how to use a DLL function that has LPCTSTR arguments?
Thanks.
|
|
|
|
|
Hi there. I think the declaration of ByVal arg2 as String is correct for working with LPCTSTR types. I wonder if declaring the return type as Boolean is where the problem is. Try declaring the return type as Long instead.
|
|
|
|
|
The return type in the DLL is Boolean. I tried declaring the return type as Long, but it doesn't seem to work.
I'm trying to set an If statement to ensure the function is working properly:
Dim errtcp As Long
errtcp = function_Name(txtip, txtport)
If errtcp = 0 then
isopen = true
else
msgbox "error"
exit sub
end if
The function always seems to open, errtcp = 0, even though in certain cases I know it should not work.
Do you have anymore ideas?
|
|
|
|
|
Hi there. So the function is being called successfully then, and seemingly returning 0 in all cases? Would you have the source code for the C function itself?
|
|
|
|
|
Here is the C code:
#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
#define API__declspec(dllexport)
#else
#define API
#endif
API boolean function_name(LPCTSTR arg1,LPCTSTR arg2 );
I'm thinking the API has something to do with my problem.
Thanks for your help!!
|
|
|
|
|
Hi
I you must use __stdcall in the functions exported to VB:
(if I remember correctly) the usage is like this:
<br />
API __stdcal boolean function_name(LPCTSTR arg1,LPCTSTR arg2 );<br />
|
|
|
|
|
Sorry about that. Here is the code I am using. I already updated to _stdcall. I submitted the old version of the code by mistake.
#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
#define API
#define CALL __stdcall
#else
#define API
#define CALL
#endif
API boolean CALL function_name( LPCTSTR arg1,LPCTSTR arg2);
The function is recognized in VB fine, I just can't seem to pass the arguments properly. Any Ideas??
|
|
|
|
|
i need to print report using datareport but i want to give query in runtime but i know how to parse query using data environment
leo
Kathmandu, Nepal
|
|
|
|
|
I have a problem.I am trying to post data from vb.net file to php file.I have achieved this issue in asp file,but I can't realize on php file.Here is my pseudocode for asp file:
Request = WebRequest.Create("http://" & Me.TextBox3.Text & ":" & Me.TextBox4.Text & "/default.php")
Request.Method = "POST"
Dim vHeaders As Object
vHeaders = "Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13)
Dim sUserNameParameter As String = "UserName="
Dim sPasswordParameter As String = "Password="
Dim sPostData As String = sUserNameParameter & Me.TextBox1.Text & "&" & sPasswordParameter & Me.TextBox2.Text
Dim oByteString() As Byte
oByteString = ASCIIEncoding.ASCII.GetBytes(sPostData)
Request.ContentType = vHeaders
Request.ContentLength = oByteString.Length
Dim myStream As Stream
myStream = Request.GetRequestStream()
myStream.Write(oByteString, 0, oByteString.Length)
myStream.Close()
Request.Timeout = 10000
Respond = Request.GetResponse()
After that code , I take the response from the asp file and I process the data belonged to the response.
So, How can I post data to php file served by apache server?
Thanks...
|
|
|
|
|
Hi People,
After several unsuccessful attempts to use Outlook 2002/ 2003/ Exchange rules, I am unable to autoreply to all mesages received to a particular inbox.
I have set up a new mail enabled user with the sole purpose of autoreplying to messages sent to a distribution list of which this new user is a member.
Are any of you VBS guru'a able to come with something which would do the trick?
Many, many thanks in advance
|
|
|
|
|