Click here to Skip to main content
15,897,153 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Register Wiaaut.dll Pin
Dave Kreskowiak11-Mar-12 10:13
mveDave Kreskowiak11-Mar-12 10:13 
GeneralRe: Register Wiaaut.dll Pin
ivo7511-Mar-12 10:37
ivo7511-Mar-12 10:37 
AnswerRe: Register Wiaaut.dll Pin
YuanJianzhong25-Mar-12 15:09
YuanJianzhong25-Mar-12 15:09 
QuestionExecuteScalar won't work? Pin
Midnight Ahri9-Mar-12 14:32
Midnight Ahri9-Mar-12 14:32 
AnswerRe: ExecuteScalar won't work? Pin
Dave Kreskowiak9-Mar-12 15:12
mveDave Kreskowiak9-Mar-12 15:12 
AnswerRe: ExecuteScalar won't work? Pin
Shameel10-Mar-12 17:47
professionalShameel10-Mar-12 17:47 
GeneralRe: ExecuteScalar won't work? Pin
Shameel11-Mar-12 19:32
professionalShameel11-Mar-12 19:32 
QuestionSetup DSN programmatically on the fly Pin
KreativeKai9-Mar-12 8:03
professionalKreativeKai9-Mar-12 8:03 
Hi all, Hope someone can help with this...
I wrote this code several years ago and it has worked great in XP. Our department is rolling out Windows 7 and the agency that uses the app I wrote are finally receiving their new Windows 7 systems.

One problem... code doesn't work any longer.

The code sets up a DSN entry on the fly. In XP, a standard user without any elevated rights could run the app and this code worked.

Now in Windows 7 when installing, I have the end user setup as local administrator and the app fails to Create the DSN. If I go in and right click on the "Click-Once" setup.exe and select "Run as administrator" it works. Also if I create a shortcut to the setup.exe and change the advanced settings to "Run as administrator" it also works from that shortcut.

If I use the icon created by the program from the "Start" menu or from the desktop, which doesn't have an option to "Run as administrator", even though the client is setup as local administrator, it kicks an error that it can't create the DSN. I can delete the DSN and see when it is created and when it can't and it coincides with the trials I've listed above.

Is there something I can put in code that allows it to work no matter if administrator or if a standard user, like it did in XP? Some google posts talk about UAC causing the problem, but just say they recommend to run as administrator.

I've searched google and code project, and most articles / posts seem to be from 2004 or around that time. We're using VS 2010... Is there a better way to creat the DSN's on the fly with VS 2010? Confused | :confused:

Here is the code
<br />
Public Declare Auto Function SQLConfigDataSource Lib "ODBCCP32.DLL" _<br />
(ByVal hwndParent As Integer, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Integer<br />
<br />
Private Const ODBC_ADD_SYS_DSN As Integer = 4<br />
<br />
Friend Shared Sub Create_DSN_For_Crystal_Reports()<br />
  Try<br />
    Dim attributes As New System.Text.StringBuilder()<br />
    Dim returnCode As Integer<br />
<br />
    attributes.Append("DSN=CCPROD")<br />
    attributes.Append(Chr(0))<br />
    attributes.Append("Server=CCPROD")<br />
    attributes.Append(Chr(0))<br />
    attributes.Append("Description=DSN added via code from Beneficiary System")<br />
    attributes.Append(Chr(0))<br />
    attributes.Append("Database=HrPr")<br />
    attributes.Append(Chr(0))<br />
    attributes.Append("AnsiNPW=Yes")<br />
    attributes.Append(Chr(0))<br />
    attributes.Append("QuotedId=Yes")<br />
    attributes.Append(Chr(0))<br />
    attributes.Append("Trusted_Connection=Yes")<br />
    attributes.Append(Chr(0))<br />
    attributes.Append(Chr(0))<br />
<br />
    returnCode = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, "SQL Server", attributes.ToString)<br />
<br />
    If returnCode <> 1 Then<br />
      Throw New Exception("DSN could not be setup to allow Crystal Reports access - Contact Programming Staff")<br />
    End If<br />
  Catch ...     <br />
    ...<br />
  End Try<br />
End Sub<br />

Lost in the vast sea of .NET

AnswerRe: Setup DSN programmatically on the fly Pin
Dave Kreskowiak9-Mar-12 15:09
mveDave Kreskowiak9-Mar-12 15:09 
GeneralRe: Setup DSN programmatically on the fly Pin
KreativeKai12-Mar-12 1:17
professionalKreativeKai12-Mar-12 1:17 
GeneralRe: Setup DSN programmatically on the fly Pin
Dave Kreskowiak12-Mar-12 5:02
mveDave Kreskowiak12-Mar-12 5:02 
GeneralRe: Setup DSN programmatically on the fly Pin
KreativeKai12-Mar-12 7:26
professionalKreativeKai12-Mar-12 7:26 
Questionhi Pin
hisuka139-Mar-12 2:16
hisuka139-Mar-12 2:16 
AnswerRe: hi Pin
Simon_Whale9-Mar-12 2:34
Simon_Whale9-Mar-12 2:34 
AnswerRe: hi Pin
Dave Kreskowiak9-Mar-12 3:12
mveDave Kreskowiak9-Mar-12 3:12 
QuestionMaking a programming language in VB Pin
Member 83786918-Mar-12 22:29
Member 83786918-Mar-12 22:29 
AnswerRe: Making a programming language in VB Pin
Simon_Whale8-Mar-12 22:44
Simon_Whale8-Mar-12 22:44 
GeneralRe: Making a programming language in VB Pin
Member 837869112-Mar-12 21:47
Member 837869112-Mar-12 21:47 
GeneralRe: Making a programming language in VB Pin
Simon_Whale12-Mar-12 23:14
Simon_Whale12-Mar-12 23:14 
AnswerRe: Making a programming language in VB Pin
Bernhard Hiller9-Mar-12 2:26
Bernhard Hiller9-Mar-12 2:26 
AnswerRe: Making a programming language in VB Pin
Bert Mitton9-Mar-12 7:40
professionalBert Mitton9-Mar-12 7:40 
AnswerRe: Making a programming language in VB Pin
Johan Hakkesteegt12-Mar-12 1:56
Johan Hakkesteegt12-Mar-12 1:56 
QuestionMultiple Keys Combination using Select Case Pin
Midnight Ahri8-Mar-12 19:47
Midnight Ahri8-Mar-12 19:47 
AnswerRe: Multiple Keys Combination using Select Case Pin
Richard MacCutchan8-Mar-12 21:34
mveRichard MacCutchan8-Mar-12 21:34 
QuestionSerializer complex class Pin
boagrius8-Mar-12 13:42
boagrius8-Mar-12 13:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.