|
Remote from my office to my home server. I connect using my IP addrss.
Richard Deeming wrote: Check which client protocols are enabled on the computer that's trying to connect. If it doesn't have the SQL configuration tools installed, you'll need to run cliconfg.exe from both C:\Windows\System32\ (64-bit) and C:\Windows\SysWow64\ (32-bit).
Well, that did it!!!
Wow, I've been trying on & off again for MONTHS to get this to work. THANK YOU!!
I've set up SQL Remote access before, and I don't remember ever having use 'cliconfg.exe' before. Is this documented somewhere?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I can't see an MS documentation, but there are various blogs describing the tool - for example:
How to setup and use a SQL Server alias[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Awesome, thanks!
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Kevin Marois wrote: I take all this back. As soon as I posted I thought, I'll give it one more try - and it connected
Isn't that always the way it goes?
Glad you got it sorted.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi all,
When I exporting Database table to Excel my date fields are giving 23/01/1990 00:00:00 in stat of 23/01/1990
Please can some one help me in the right way.
Quote: protected DataTable ExportDataFromSQLServer()
{
DataTable dataTable = new DataTable();
using (SqlConnection connection = new SqlConnection(@"Data Source= 127.0.0.1\MSSQLSERVERJAN; Initial Catalog=BHV; User ID=sa;Password=XXXXXXX"))
{
connection.Open();
// Define the query to be performed to export desired data
SqlCommand command = new SqlCommand("select * from BHVUsers", connection);
SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
dataAdapter.Fill(dataTable);
var excelApplication = new Excel.Application();
var excelWorkBook = excelApplication.Application.Workbooks.Add(Type.Missing);
DataColumnCollection dataColumnCollection = dataTable.Columns;
for (int i = 1; i <= dataTable.Rows.Count + 1; i++)
{
for (int j = 1; j <= dataTable.Columns.Count; j++)
{
if (i == 1)
excelApplication.Cells[i, j] = dataColumnCollection[j - 1].ToString();
else
excelApplication.Cells[i, j] = dataTable.Rows[i - 2][j - 1].ToString();
}
}
excelApplication.Cells[1, 2] = "Voornaam";
excelApplication.Cells[1, 3] = "Achternaam";
excelApplication.Cells[1, 4] = "Geboorte Datum";
excelApplication.Cells[1, 5] = "Porto nummer";
excelApplication.Cells[1, 6] = "EHBO behaald";
excelApplication.Cells[1, 7] = "EHBO";
excelApplication.Cells[1, 8] = "BHV";
excelApplication.Cells[1, 9] = "Regisseur";
excelApplication.Cells[1, 10] = "Verlopen EHBO";
excelApplication.Cells[1, 11] = "Laatste herhaling EHBO";
excelApplication.Cells[1, 12] = "EHBO nummer";
excelApplication.Cells[1, 13] = "Verdieping";
excelApplication.Cells[1, 14] = "Ruimte";
excelApplication.Cells[1, 15] = "Email";
excelApplication.Cells[1, 16] = "Mobiel";
excelApplication.Cells[1, 17] = "Opmerking";
excelApplication.Cells[1, 18] = "BHV_Behaald";
excelApplication.Cells[1, 19] = "BHV_Verlopen";
excelApplication.Cells[1, 20] = "Laatste_Herhaling_BHV";
excelApplication.Cells[1, 21] = "Ruisnaam";
excelApplication.Cells[1, 22] = "Regisseur_Verlopen";
excelApplication.Cells[1, 23] = "Regisseur_Behaald";
excelApplication.Cells[1, 24] = "Regisseur_Herhaling";
excelApplication.Cells[1, 25] = "Active_no_yes";
excelApplication.Cells[1, 2].Font.Bold = true;
excelApplication.Cells[1, 3].Font.Bold = true;
excelApplication.Cells[1, 4].Font.Bold = true;
excelApplication.Cells[1, 5].Font.Bold = true;
excelApplication.Cells[1, 6].Font.Bold = true;
excelApplication.Cells[1, 7].Font.Bold = true;
excelApplication.Cells[1, 8].Font.Bold = true;
excelApplication.Cells[1, 9].Font.Bold = true;
excelApplication.Cells[1, 10].Font.Bold = true;
excelApplication.Cells[1, 11].Font.Bold = true;
excelApplication.Cells[1, 12].Font.Bold = true;
excelApplication.Cells[1, 13].Font.Bold = true;
excelApplication.Cells[1, 14].Font.Bold = true;
excelApplication.Cells[1, 15].Font.Bold = true;
excelApplication.Cells[1, 16].Font.Bold = true;
excelApplication.Cells[1, 17].Font.Bold = true;
excelApplication.Cells[1, 18].Font.Bold = true;
excelApplication.Cells[1, 19].Font.Bold = true;
excelApplication.Cells[1, 20].Font.Bold = true;
excelApplication.Cells[1, 21].Font.Bold = true;
excelApplication.Cells[1, 22].Font.Bold = true;
excelApplication.Cells[1, 23].Font.Bold = true;
excelApplication.Cells[1, 24].Font.Bold = true;
excelApplication.Cells[1, 25].Font.Bold = true;
int k = 0;
for (k = 1; k <= 23; k++) // this will aply it form col 1 to 10
{
excelApplication.Columns[k].ColumnWidth = 30;
}
Excel.Range formatRange; formatRange = excelApplication.get_Range("a1", "y1");
formatRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightBlue);
//excelApplication.Cells[1,1] = "LightBlue";
formatRange = excelApplication.get_Range("a1", "y1");
formatRange.BorderAround(Excel.XlLineStyle.xlContinuous,
Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex.xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic);
// Save the excel file at specified location
excelApplication.ActiveWorkbook.SaveCopyAs(@"C:\tmp\test1.xlsx");
excelApplication.ActiveWorkbook.Saved = true;
MessageBox.Show("Excel file created , you can find the file " + "c:\\tmp\\test1.xlsx");
System.Diagnostics.Process.Start("c:\\tmp\\test1.xlsx");
// Close the Excel Application
excelApplication.Quit();
connection.Close();
//Release or clear the COM object
releaseObject(excelWorkBook);
releaseObject(excelApplication);
}
Thanks
Regards,
Jan Meeling
modified 19-Aug-19 7:40am.
|
|
|
|
|
Where is the code that transforms the Date fields?
|
|
|
|
|
Hi Richard,
I was trying that with no results.
Do yoy have a solution how to do this.
Thanks,
Regards,
Jan Meeling
|
|
|
|
|
|
jan Meeling wrote: I was trying that with no results. Trying what? Please show the code that saves, and formats, the Date field(s).
|
|
|
|
|
Did you try to set the cell format as DATE, not DateTime?
|
|
|
|
|
Hi Victor,
Thanks for your quick response.
Do you have the phrase How I have to implement.
Thanks
Regards,
Jan Meeling
|
|
|
|
|
Usually you don't include the password for the sa-account in the question. Usually we also frown on "SELECT *", and weirdly, you use a "using" clause for the connection but not for the disposable command.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi Bastard,
I have removed the password and this is only in a test enviroment,
And what do you mean with
Usually we also frown on "SELECT *", and weirdly, you use a "using" clause for the connection but not for the disposable command.
Thanks
Regards
Jan Meeling
|
|
|
|
|
jan Meeling wrote: Usually we also frown on "SELECT *", A select all, versus a select where you only select what you will use. You're now fetching more than expected and this may have an impact on speed.
jan Meeling wrote: and weirdly, you use a "using" clause for the connection but not for the disposable command. You put the connection in a using-block, but not the command. Any reason why?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi all,
I have it working know.
The solution is in the SQL string.
SELECT ID_BHV_Users, Voornaam , Achternaam , FORMAT (Geboorte_Datum, 'dd/MM/yyyy'), Porto_Nummer , Format (EHBO_Behaald, 'dd/MM/yyyy') , EHBO , BHV , Regiseur , Format ( Verlopen, 'dd/MM/yyyy') , Format (Laatste_herhaling, 'dd/MM/yyyy') , EHBO_nummer , verdieping , Ruimte , Email , Mobiel , Opmerking , Format (BHV_Behaald, 'dd/MM/yyyy') , Format (BHV_Verlopen, 'dd/MM/yyyy') , Format (Laatste_Herhaling_BHV, 'dd/MM/yyyy') , Ruisnaam , Format (Regisseur_Verlopen, 'dd/MM/yyyy') , Format (Regisseur_Behaald, 'dd/MM/yyyy') , Format (Regisseur_Herhaling, 'dd/MM/yyyy') , Active_no_yes FROM BHVUsers"
I use the format in the SQL string
You All thanks for putting me in the right direction.
Thanks
Jan Meeling
|
|
|
|
|
Well that is even worse than where you started from. Do not use formatted date strings but use proper date values and Date types. Also use proper parameterised queries to avoid SQL injection problems.
|
|
|
|
|
Hi Richard,
Thanks for reaction.
Can you give me the right way how to do is.
I now about SQL injection problems but this not connected to the internet and only in my test environment.
Thanks,
regards,
Jan Meeling
|
|
|
|
|
|
Hi all,
I have it working know.
The solution is in the SQL string.
SELECT ID_BHV_Users, Voornaam , Achternaam , FORMAT (Geboorte_Datum, 'dd/MM/yyyy'), Porto_Nummer , Format (EHBO_Behaald, 'dd/MM/yyyy') , EHBO , BHV , Regiseur , Format ( Verlopen, 'dd/MM/yyyy') , Format (Laatste_herhaling, 'dd/MM/yyyy') , EHBO_nummer , verdieping , Ruimte , Email , Mobiel , Opmerking , Format (BHV_Behaald, 'dd/MM/yyyy') , Format (BHV_Verlopen, 'dd/MM/yyyy') , Format (Laatste_Herhaling_BHV, 'dd/MM/yyyy') , Ruisnaam , Format (Regisseur_Verlopen, 'dd/MM/yyyy') , Format (Regisseur_Behaald, 'dd/MM/yyyy') , Format (Regisseur_Herhaling, 'dd/MM/yyyy') , Active_no_yes FROM BHVUsers"
I use the format in the SQL string
You All thanks for putting me in the right direction.
Thanks
Jan Meeling Smile | Wink |
|
|
|
|
|
I have a product that offers a small lead management system. The architecture of product is simple so far. I have tables called 'companies', 'users', 'leads'. Users within a company have CRUD rights on leads. Now companies want their agents to have rights to operate leads. So we can ask companies to add their agent as a user within the company but there is a problem. Each user needs to have a unique email to register. So if one agent serves 5 companies they can't be added as a user by each of them. What should be the ideal way to handle this.
Thought of having separate database for each company so that problem of unique email is resolved but I'm not sure how to manage multiple databases for updates
|
|
|
|
|
You may want to change the "key" to the Users table to be a compound key.
Something like Company ID + user email, this would ensure that within a single company, the email is unique.
|
|
|
|
|
With company id + user email, the sign in logic will fail.
Right now user can sign in with email as its unique.
|
|
|
|
|
Add another table with 3 fields
AgentID PK
UserID (could be the email if it is the PK in the user table) - FK to users
CompanyID - FK to company
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I have an ecommerce shop online using php, sql, javascript,ajax and sessions.
I have both guest and members cart options at checkout.
Everything works fine.
I store my cart items in a session currently.
Users can log in or have a guest cart.
Guests cart userids are referenced by the current session id.
members can login and their carts are referenced by their usersids from the database.
The problem is, the session expires after a certain amount of time and so the cart items are lost and the user has to start again.
On doing some research I have found that after the user logs in, I can store his user id in a cookie and I can specify how long that cookie lasts for which is ideal!
I am thinking of changing the code so that I store the items added to the cart in my database tables and simply reference them with the user id ive stored in his cookie.
That way He can shop for ages and not lose his cart and I can send abandon cart emails etc...
I think this would work well as nearly every website uses cookies so people have to have them enabled in their browser these days. I could show a warning message if cookies arent enabled anyway..
What does everyone think about this?
Please note I am not seeking security advice here.
|
|
|
|
|