|
I have actually solved the problem of defining the steps for installer.
|
|
|
|
|
Hi
Thanks. I was able to sort out according to the required steps.
This issue can be treated as closed.
|
|
|
|
|
Hello which is the best way of connecting VB6 application with sql serverv 2000 ?
|
|
|
|
|
VB6 support ended in april 2008. Support for Sql Server 2000 ended in april 2013[^]. The combination will be limited to 32-bits, and, hence, 32-bit libraries and controls.
The "best" way to connect a VB6-application has not changed; you'd use ADOX as described. There's enough examples on the internet[^].
I'd also like to point out that there are FREE alternatives to the tools you named; VB.NET can be downloaded for free (search vb.net express) and same goes for Sql Server (search for sql server express). There's a LOT more examples on using those, as they have replaced the older tools.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello !
I have an application on Visual Basic 2013 , Entity Framework 6.02 , Sql server 2008R2.
I have several identical databases.
on design , I have created through wizard the connection with one of them ( For example MyDB1) and I have configured the Entity. Now , on runtime , I want to give the users the possibility to disconnect from the database MyDB1 and to connect to another (identical) database for example MyDb2.
How can I do this through code ?
Thank you !
|
|
|
|
|
There are two things you have to do. The first is change the connection string to whatever you need.
All you have to do is replace the part of the connection string that specifies the database and/or server name the database is on.
The second is that you have to wrap your DbContext class with a partial class and supply a new constructor that accepts a connection string:
Partial Public Class MyDbContext
Public Sub New(connectionString As String)
If String.IsNullOrWhiteSpace(connectionString) Then
Throw New ArgumentNullException("connectionString")
End If
Database.Connection.ConnectionString = connectionString
End Sub
End Class
Whenever you need to create a new instance of your DbContext, you just pass the connection string to the wrapper which will pass it to the ConnectionString property of the DbContext for you.
|
|
|
|
|
Hello !
But how to change the connection string ?
As I can see inside visual studio , the connection string is inside the app.config.How can I change on runtime the part that specifies the database and server ?
For the second thing , where should I put the code ?
And finally , let suppose that I have a textbox where I write the name of the database that i want to connect. And I have a button that make the connection. What code should I pass to the button.click event ?
Thank you !
|
|
|
|
|
This is simple string manipulation. In the app.config file, replace the database name in the connection string with a tag that's easily locatable, like this:
Server={SERVER};Database={DATABASENAME};User Id=myUsername;Password=myPassword;
* This connection string will only an example. Copying and pasting it will do you no good.
The tags, "{SERVER}" and "{DATABASENAME}" are easily found by code and replaced with a line like this:
Dim newConString As String = connStringTemplate.Replace("{SERVERNAME}", serverName).Replace("{DATABASENAME}", databaseName)
|
|
|
|
|
in my app.config , there are many lines , but Connection string is :
<connectionStrings>
<add name="MyEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=USER-PC;initial catalog=MyDB1;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
I don't have Server=.... and Database=....
???
|
|
|
|
|
Excuse me, but where in this process did I say "stop thinking for yourself"?
Do you see anything in your connection string that looks familiar?? Like that "MyDB1" looks like your database name!!
How about "USER-PC"?? Doesn't that look like the name of your own workstation?? You apparently have SQL Server installed on your machine!
|
|
|
|
|
Thank you !
in this line :
Dim newConString As String = connStringTemplate.Replace("{DATABASE}", "MyDB2")
I get an error connStringTemplate is not decared.
How should I declare ?
Thank you !
|
|
|
|
|
That's what you get for blindly copying and pasting code without thinking about it. You're not even ATTEMPTING to figure out what's going on, are you?
That variable doesn't exist in your code because IT'S AN EXAMPLE! connStringTemplate would be replaced by the variable you define in your code that is holding the connection string template that you're searching and replacing the tags in.
Start THINKING!
|
|
|
|
|
Thank you !
I thought that connStringTemplate was a system object that hold the connection string.
Ok but if I declare this variable , how can I set his value to current connection string ?
Thank you !
|
|
|
|
|
|
Thank you !
This is my code for changing the connection String :
Dim connstringtemplate As String = System.Configuration.ConfigurationManager.ConnectionStrings(1).ConnectionString.ToString
Cnstring = connstringtemplate.Replace("{DATABASE}", "MyDB2")
This is My partial class
Partial Public Class MyEntities
Inherits DbContext
Public Sub New(connectionString As String)
If String.IsNullOrWhiteSpace(connectionString) Then
Throw New ArgumentNullException("connectionString")
End If
Database.Connection.ConnectionString = connectionString
End Sub
Entity declaration :
context = New MyEntities(cnstring)
But now on runtime i get an error on the line
Database.Connection.ConnectionString = connectionString
An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
Additional information: Keyword not supported: 'metadata'.
|
|
|
|
|
Please , any help what can I do ?
Thank you !
|
|
|
|
|
alejx wrote: what can I do ?
Learn to use the debugger built into Visual Studio.
Obviously, it's compaining about something in the connection string, but there's no way for anyone but YOU to determine what that is.
|
|
|
|
|
Thank you !
The error that I get is :
An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
Additional information: Keyword not supported: 'metadata'.
And on my connection string in app.config I have "metadata" keyword :
<connectionStrings>
<add name="DyqaniEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=USER-PC;initial catalog=Dyqani;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
If metadata is not supported , what can I do for my connection string ?
thank you !
|
|
|
|
|
Did you actually READ with your own eyes the string you got back?? See the little path in there that starts with provider connection string ?? What do you think that is between the double quote marks?
Think about that for a while.
|
|
|
|
|
I'm sorry !
I can't understand.
The original string from app.config is :
<connectionStrings>
<add name="DyqaniEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=USER-PC;initial catalog={Database};integrated security=True;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
After the replace instruction :
Cnstring = connstringtemplate.Replace("{DATABASE}", "MyDb2")
The string become :
add name="DyqaniEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=USER-PC;initial catalog=MyDB2;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
The only thing that I understand from the error message is that on the connection string there is metadata keyword that is not supported (according to error message).
Please tell me what's wrong
Thank you !
|
|
|
|
|
I've given you everything you need. I've told you exactly where to look. No, I'm not spoon feeding you this stuff and I am not writing your code for you. I've got my own 50,000 line app I've got to get running.
|
|
|
|
|
|
Good friends! Please I need your help. Is it possible to write a program that can get scanned document contents, then paste it on a textbox using vb.net or vb6.0? That is, if you scan hardcopy of ms word so that you can save typing time by just editing it using any program. Can this application be develop with vb6.0 or vb.net? Please help!!!
|
|
|
|
|
This can be made, but is is quite complicated and you would reinvent the wheel. What you need is an OCR API or software, have a look at this question[^] for more info.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Entropy isn't what is used to.
|
|
|
|
|
Hi
Please help me to resolve this issue.
I have configured my DB2 Connection string in Registry with the Instance NAme as DB2 .
My Connection string key contains
Provider , Database , Host name , Protocol , PORT , USERID , PASSWORD , Authenthication.
I have a Code in VB like..
sSQL = UPDATE <stmt>...
Set UPDATECAL = DATALAYER.ExecSQLUpdate(INSTANCE_NAME, sSQL)
Instance name written DB2 as constant.
I am getting failure after executing this..
The connection cannot be used to perform this operation. It is either closed or invalid in this context.
I guess it is not recognizing this connection.
Please help me...if required i will post more information.
|
|
|
|