|
i understand your anwser but my question is this
the query is autogenerated in a form of string in a text box
so how can i pass the string query and save it as a view
using sqldmo
|
|
|
|
|
Try something like this
You will have to fill in the blanks for connections string etc..
Before some pipes up with "injection attacks security risks etc..."
This is a very basic code to give an idea of how it could work.
=========================
string MySQL = TextBox1.Text; // SQL in the view select * from table
string MyViewName = TextBox2.Text; // The view name on DB
SQLstring = "CREATE VIEW " + MyViewName + " AS " + MySQL
SqlConnection myConnection = new SqlConnection(strConnectSQL);
SqlCommand myCommand = new SqlCommand( SQLstring, myConnection );
try
{
myConnection.Open();
myCommand.ExecuteScalar();
myConnection.Close();
}
catch
{
myConnection.Close();
}
|
|
|
|
|
I'm working with some people on other countries. I want all people will work
on the same database at certain server. Help me ASAP ! Thanks !
Hung
|
|
|
|
|
What version of SQL Server are you using ? I know this can be done, as I've connected to a SQL Server instance for a client in the USA, but I'm not sure how it's configured. I know SQL Server 2005 has a lot of new online functionality, but this was SS2000, I am certain.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I've connected directly to a SQL Server 2000 instance over the internet through a VPN connection. It was a bit slower than on the LAN, but that was only to be expected.
You can connect directly too, but even although my SQL Server is patched upto date I wouldn't want to expose it. My firewall log shows several blocked attempts at getting to SQL Server on my machine.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
I think There are several ways of doing this but of which i pretty much sure about is running your sql server instance on a server with Static IP. You also need to configure listener ports on the server.
The connection string will look something like this
This is Oledb provider
Provider=sqloledb;Data Source=10.20.50.100,1521;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd
if you are using Sql client on a Net framework skip the provider part and rest is same.
I hope this is helpful enough
Mandar Patankar
Microsoft Certified professional
|
|
|
|
|
Create hole in the firewall on a different port than standard SQL server and use NAT to move this each side of the firewall. Also filter the IP address range if possible (providing others have fixed IP addresses.)
|
|
|
|
|
I have a small problem with M.Access. I have a form which achieves data from the 'select' query. Beside, this form has the Default View of Continuous Forms and the the scroll-bar property of Vertical only. However, when I run the form, the form always shows the vertical scroll-bar despite of the number of records.
I ever saw another form having the same property with the above form. In contrast, this form only shows the vertical scroll-bar when necessary.
please show me the way to solve this problem. I'm in dark. Thanks a lot.
<vtalau>.
|
|
|
|
|
I am not an ADO expert -- but I have ADO code to fix...
I've got this process which talks to the SQL server a lot. But over time, we start to get errors on the connection. We basically open a single ADO connection and reuse it for all of our stored procedure needs.
My question is this -- is this an appropriate and efficient way to use it. To just open one connection and use it forever.
OR -- is it appropriate to open a connection each time we do a stored procedure?
Also, if the single connection approach is appropriate, how does one fix a messed up connection?
I am just looking for some practical guidelines toward using ADO.
(1) Should I use a single shared connection?
(2) Should I Open() a connection for each stored procedure transaction?
(3) What's the best way to correct a screwed connection?
Thanks in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
I've never experienced this problem.
Normally, the recommended pattern is to create a connection for each operation or small group of related operations. With connection pooling enabled (the default), ADO will keep the physical connection open so it can be reused as required, creating additional connections only as they're needed. Connections that have been idle for a long time will eventually be disconnected.
Most connection objects are not thread-safe, IIRC. If there's a chance you're using your single connection object from multiple threads concurrently, this could well be causing your errors. Switching to a connection-per-operation model should sort this problem out.
In fact the ADO Connection object is marked as Apartment threaded. If you're using the correct operations to pass interface pointers between threads in a multithreaded program, calling a Connection object method will cause COM to marshal the call back to the thread that created the object. If you're not doing it properly, passing raw pointers around, then you could well be corrupting the internal state of the object.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks for the clarification. I am no ADO expert, and it seems we have no expert on staff. I changed the code to make a new connection for each operation, and it seems pretty happy.
Thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
i'm going to have an 'after update' trigger. but in that trigger i want to know which row has been updated causing this triger. in that triger i want to update another row in other table by id of that updated row.
please help me.
Thanks
Rastegar
|
|
|
|
|
You don't write what DBMS you use !
If you use MS SQL Server you can use in a trigger following tables:
Inserted (inserted ) & Deleted (deleted).
delete table store old values , old records/rows.
inserted table store new values , new records/rows.
For example if you have an trigger for [Order] table:
- deleted table will contain old orders (before update operation) and
- inserted table will contain new order (after update operation).
VB6,C#
|
|
|
|
|
I can't figure out what I'm doing wrong.
I want to list all employees i have by the foreman they are associated with and count the number of installs they have done for the day. I have that part working. However if they have no installs at all for the day then they don't show up at all in the query and i'm wanting a complete employee list.
can someone please help? Here is my current query.
<br />
SELECT Employees_Tony.[Employee Name], MtrInstall.InstallDate, Count(MtrInstall.NewSN) AS CountOfNewSN, MaterialType.UtilityID, Formans_Tony.[Forman Name], Formans_Tony.FormanID, Formans_Tony.FormanID<br />
FROM (MaterialType INNER JOIN MtrAccount ON MaterialType.MaterialTypeID = MtrAccount.MaterialTypeID) INNER JOIN ((Employees_Tony INNER JOIN Formans_Tony ON Employees_Tony.FormanID = Formans_Tony.FormanID) INNER JOIN MtrInstall ON Employees_Tony.[Employee ID] = MtrInstall.EmployeeID) ON MtrAccount.AccountID = MtrInstall.AccountID<br />
GROUP BY Employees_Tony.[Employee Name], MtrInstall.InstallDate, MaterialType.UtilityID, Formans_Tony.[Forman Name], Formans_Tony.FormanID, Formans_Tony.FormanID<br />
HAVING (((MtrInstall.InstallDate)=#8/16/2005#));<br />
Win32newb
"If I wrote a book like I code. It would be one page thick and contain only one word (DUH!)"
|
|
|
|
|
try this
SELECT Employees_Tony.[Employee Name], MtrInstall.InstallDate, Count(MtrInstall.NewSN) AS CountOfNewSN, MaterialType.UtilityID, Formans_Tony.[Forman Name], Formans_Tony.FormanID, Formans_Tony.FormanID
FROM (MaterialType LEFT OUTER JOIN MtrAccount ON MaterialType.MaterialTypeID = MtrAccount.MaterialTypeID) LEFT OUTER JOIN((Employees_Tony LEFT OUTER JOIN Formans_Tony ON Employees_Tony.FormanID = Formans_Tony.FormanID) LEFT OUTER JOIN MtrInstall ON Employees_Tony.[Employee ID] = MtrInstall.EmployeeID) ON MtrAccount.AccountID = MtrInstall.AccountID
GROUP BY Employees_Tony.[Employee Name], MtrInstall.InstallDate, MaterialType.UtilityID, Formans_Tony.[Forman Name], Formans_Tony.FormanID, Formans_Tony.FormanID
HAVING (((MtrInstall.InstallDate)=#8/16/2005#));
|
|
|
|
|
I have an access db used for my webapplication. I'm planning to convert to using MySQL from now on. How is the easiest way to convert my db?
|
|
|
|
|
There are several items listed on the MySQL website that claim to do this. I have tried a few demos and they certainly seem to live up to those claims. Look in the Developers section, under Migration.
|
|
|
|
|
hi, is it possible to use a XML Dokument as a Database? because i dont want to install a SQL Server!
how can i establish a Odbc or Oledb Connection to the XML Database? than i want to fill the DataSet and display it in a DataGrid!
thx in advance! bye
|
|
|
|
|
surfman19 wrote:
is it possible to use a XML Dokument as a Database?
Yes, if it is small and single user you could. However, if it got too large you would incur a large performance penalty. Also, if you need multiple users then you are going to run into all sorts of concurrency problems.
XML is not designed to be used as a database, it is good as a data transfer format though.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
which database (you need oeldb??) do you use if you want to be independent from the operating system?
bye
|
|
|
|
|
|
Yes,
MS walk through using ReadXML.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkWalkthroughAccessingXMLData.asp
|
|
|
|
|
I know sql pretty well but am new to ado.net.
Can anyone suggest a quick reference on SQL commands and syntax that will work with ODBC or OleDb flat-files? Or that will work separately with non-SqlServer datasets in general?
For instance, I'd like to be able to use a t-sql style 'case-when-then' statement but am having no luck using it to pull records from a fixed-width text file I'm connecting to via an ODBC connection (a simple select with a where and order-by clause works fine).
My goal here is to be able to quickly find the syntax for all legal SQL statements within a given context, like any of us would expect with a regular t-sql manual, and know it will apply in a given environment.
I am not finding much help in the vs.net help files or web searches. Maybe I'm not looking in the right place or using the right search expressions? Everything seems to either be rudimentary select statements or assume you are using Sql Server databases.
In case it's helpful: I'm currently working on a console application in vb.net that needs to batch-process data in flat-files we get nightly, massaging the data with conditionals and some string manipulation, and updating other files. It should be possible to handle most of the process with a handful of SQL statements but I'm now looking at writing a bunch of nested vb routines instead. Not happy.
Thanks in advance for any help.
|
|
|
|
|
I have a DataTable with composite key bounded to the DataGrid.
So when the user inserts some data which violates the constraint, an exception is thrown.
What is the right place (event etc) to do any additional custom Validation?
Another problem is the the message that DataTable throws is not user friendly? How can I stop it and give a more meaningful message?
The message I got is
"Error when committing the row to the original data store"
|
|
|
|
|
hi all,
i want to know how to select as item from the dropdownlist in the datagrid
and have the textbox in the datagrid filled with the corresponding value from database.
for eg if i select product name from dropdownlist then the textbox in datagrid must be populated with the price from the database for the corresponding product name.
|
|
|
|