|
temp = System.IO.Path.GetFullPath("Data.mdb")
temp = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=" & temp & ";Mode=ReadWrite;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="####";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"
OleDbConnection1.ConnectionString = temp
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
This is an example with a database from data.mdb file (Access file)!
First, I put in temp the path.
Next, I put in temp the connection string of database (in field #### you must write the password)
*I am not 100% sure if it wants password there or in first line! Make combinations!
And finally, I change the connecion string of my OledbConnection..
-- modified at 19:16 Monday 6th February, 2006
|
|
|
|
|
I'll try your solution.
At this moment, I'm building my software without database password. I'll try your solution and then inform you. While please tell me, in your solution, you use Password string many times and in the end advice me to enter my password in place of ####, tell me I only have to enter password in place of #### or everywhere you use Password.
|
|
|
|
|
Look..
I am not sure 100%,that I told you..so, make some combinations for the "where", but you can find informations for this in Web..Sorry for my incomplete help..but i dont want make mistakes and make difficult your job..
Friendly..
|
|
|
|
|
OK I'll try different combinations.
Tell me how this line of code will work.
temp = System.IO.Path.GetFullPath("Data.mdb")
What I understand is this:
>>First you declare temp as string
Now tell me how VB.NET knows where is Data.mdb, I mean did you include it in project as something & if you did tell me how? All steps in detail please of the above line.
|
|
|
|
|
Ok listen...
First of all:
Imports System.IO 'on the top of your code
Dim temp as string 'in your code
Next step, is to add the .mdb file (Access file) (for example Data.mdb) to your project! Because in the future, you may built a setup to install this program in other computers, its good this file have the path of your .exe, so you must add it in C:\...\EXAMPLEPROJECT\bin if you have Visual Studio 7 or in C:\...\EXAMPLEPROJECT\bin\Debug\ if you have Visual Studio 8!
So this code line [temp = System.IO.Path.GetFullPath("Data.mdb")] take the path of your .exe and add in the end of this string the "\Data.mdb"..so you have the path of your Access file, which now is in folder with your .exe!
If you have more questions..tell me...
I hope I help you... ;)
-- modified at 16:26 Friday 10th February, 2006
|
|
|
|
|
Thanx a lot.
Sorry for late reply.
|
|
|
|
|
I am using SQL Server 2000 as my DB and 2003 is my Dev environment. I wanted to know is there any method by which I can get number of parameters in any give Stored procedure.
-Krishnaraj
|
|
|
|
|
I am not expert, so I don't know exectly but I'll tell you that I think. Ok?
If you use
exec sp_helptext 'StoredProcedureName'
you'll get the Text . Using that text you can count your parameter. Have a nice job.
!alien!
|
|
|
|
|
There is a better way than the one already suggested.
SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
WHERE SPECIFIC_NAME='StoredProcedureName'
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Thank you, it’s a great information.
But earlier I did it with the below code. Can you make any suggestion on this. My actual intention was to check whether particular column exists in sp’s parameter list.
Declare @Id as numeric
Select @Id = id from sysobjects where name like '%SP_Name%'
Select * from syscolumns where name like 'Column_Name' and Id =@id
Krishnaraj
|
|
|
|
|
That sould be more efficient if you did WHERE name = 'SP_Name'
Let's say you have a two stored procedures called GetData and GetDataForUser . You want to find the number of parameters for GetData . Using the code you supplied you can't tell if it will return the parameters for GetData or GetDataForUser because you gave it wild cards which say that you are looking for a procedure with GetData somewhere in the name.
I would suggest that the INFORMATION_SCHEMA.PARAMETERS way is easier to work with. If you examine the properties of the view itself, you'll see that it is just using sysobjects and syscolumns as well.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Yes, you are right, I just checked by running both queries simultaneously and I found that the code you have suggested executed faster then mine.
Thanks a lot…..
Krishnaraj
|
|
|
|
|
Thank you very much.
Your code is also helpful to me.
!alien!
|
|
|
|
|
Hi!
When I change connectionstring(server changes)in run time my crystal report does not work and I neet to change in crystal report in design time. I want to fix it. How do I fix it.
If possiable,Please give me two example.
One for SQL Server Authentication and another for Windows Authentication.
Please someone help me.
!Thank!
!alien!
|
|
|
|
|
i had the same problem but u can connect using ODBC and from ODBC u can change the path or the link to the dataBase
|
|
|
|
|
Do we have any key word or special word "ADMINISTRATOR" in VB6.0
|
|
|
|
|
No, why?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I have created a new font file. I want change the font in the title bar with that font, but I do not like to change Display Properties or create a custom title bar. How can I do this
Please help me
Thank you,
chatura
|
|
|
|
|
You can't. Those are the only two options you have.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
OK, thank you for saving my time.
chatura
|
|
|
|
|
Hello!
I got an answer from Dave but whatever I tried didn't wotk out to solve PInvokeStackImbalance problem. I am using VS 2005. Eventough I changed the Integers in the GetshortPath declaration below I still got the same problem.
I have included the code below. If you can see the problem, please let me know.
Thanks!
<dllimport("kernel32.dll", setlasterror:="True," charset:="CharSet.Auto)"> _
Public Shared Function GetShortPathName(ByVal longPath As String, <marshalas(unmanagedtype.lptstr)> ByVal ShortPath As StringBuilder, <marshalas(unmanagedtype.u4)> ByVal bufferSize As Integer) As Integer
End Function
Private Function GetDosPath(ByVal LongPath As String) As String
Dim sb As New StringBuilder(1024)
On Error Resume Next '++
Dim retVal As Integer = Interop.GetShortPathName(longPath, sb, 1024) '<-- error occurs at that line
If retVal <> 0 Then
Dim sTemp As String = sb.ToString()
GetDosPath = sTemp
Else
Console.WriteLine("Error occured. GetLastError returns {0}.", Marshal.GetLastWin32Error())
End If
End Function
|
|
|
|
|
You've supplied everything except the one piece we need - the original C function header!
Is this the GetShortPathName in the WIn32 Api??? If so, then the Declare should look like this (from PInvoke.net):
<DllImport("kernel32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Shared Function GetShortPathName(ByVal longPath As String, _
<MarshalAs(UnmanagedType.LPTStr)> ByVal ShortPath As StringBuilder, _
<MarshalAs(UnmanagedType.U4)> ByVal bufferSize As Integer) As Integer
End Function
Private Sub TestShortPath()
Dim sb As New StringBuilder(1024)
Dim longPath As String
Dim sFileName As String
longPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
Dim retVal As Integer = Interop.GetShortPathName(longPath, sb, 1024)
If retVal <> 0 Then
Dim sTemp As String = sb.ToString()
MessageBox.Show(sTemp)
Else
Console.WriteLine("Error occured. GetLastError returns {0}.", Marshal.GetLastWin32Error())
End If
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 13:31 Sunday 5th February, 2006
|
|
|
|
|
Sorry Dave! Here is the class header.. Whatever I tried I got the same problem...
Public Class Interop
<dllimport("kernel32.dll", setlasterror:="True," charset:="CharSet.Auto)"> _
Public Shared Function GetShortPathName(ByVal longPath As String, <marshalas(unmanagedtype.lptstr)> ByVal ShortPath As StringBuilder, <marshalas(unmanagedtype.u4)> ByVal bufferSize As Integer) As Integer
End Function
End Class
|
|
|
|
|
No, no, no, ... The original C function header that you're trying to call, not what you think the VB declaration should be.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
GetShortPathName
The GetShortPathName function retrieves the short path form of the specified path.
DWORD GetShortPathName(
LPCTSTR lpszLongPath,
LPTSTR lpszShortPath,
DWORD cchBuffer
);
Parameters
lpszLongPath
[in] Pointer to a null-terminated path string. The function retrieves the short form of this path.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
Windows Me/98/95: This string must not exceed MAX_PATH characters.
lpszShortPath
[out] Pointer to a buffer to receive the null-terminated short form of the path specified by lpszLongPath.
cchBuffer
[in] Size of the buffer pointed to by lpszShortPath, in TCHARs.
Return Values
If the function succeeds, the return value is the length, in TCHARs, of the string copied to lpszShortPath, not including the terminating null character.
If the lpszShortPath buffer is too small to contain the path, the return value is the size of the buffer, in TCHARs, required to hold the path. Therefore, if the return value is greater than cchBuffer, call the function again with a buffer that is large enough to hold the path.
If the function fails for any other reason, the return value is zero. To get extended error information, call GetLastError.
|
|
|
|